"use strict";(self.webpackChunkpromptmanager=self.webpackChunkpromptmanager||[]).push([[39],{82400:function(e,t,n){n.d(t,{Z:function(){return h}});var i=n(1413),a=n(61889),o=n(94721),r=n(89673),l=n(55818),s=n(3721),c=n(81131),u=n(86482),d=n(80184);function p(e){var t=e.properties,n=e.disabled,i=e.readonly,o=e.uiSchema,r=e.schema,l=e.formData,s=e.onAddClick,c=e.registry,p=c.templates.AddButton;return(0,d.jsxs)(a.ZP,{container:!0,spacing:2,style:{marginTop:"10px"},children:[t.map((function(e,t){return e.hidden?e.content:(0,d.jsx)(a.ZP,{item:!0,xs:12,style:{marginBottom:"10px"},children:e.content},t)})),(0,u.Rc)(r,o,l)&&(0,d.jsx)(a.ZP,{container:!0,justifyContent:"flex-end",children:(0,d.jsx)(a.ZP,{item:!0,children:(0,d.jsx)(p,{className:"object-property-expand",onClick:s(r),disabled:n||i,uiSchema:o,registry:c})})})]})}function A(e){var t=e.properties,n=e.uiSchema,a=[],u=[];return t.forEach((function(e){n[e.name]&&"ui:advanced"in n[e.name]&&!n[e.name]["ui:advanced"]?a.push(e):u.push(e)})),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(p,(0,i.Z)({},(0,i.Z)((0,i.Z)({},e),{},{properties:a}))),(0,d.jsx)(o.Z,{style:{margin:"16px 0"}}),u.length>0&&(0,d.jsxs)(r.Z,{children:[(0,d.jsx)(l.Z,{expandIcon:(0,d.jsx)(c.Z,{}),children:(0,d.jsx)("strong",{style:{marginLeft:"5px"},children:"Advanced"})}),(0,d.jsx)(s.Z,{children:(0,d.jsx)(p,(0,i.Z)({},(0,i.Z)((0,i.Z)({},e),{},{properties:u})))})]})]})}function h(e){var t=e.idSchema;return"root"===(null===t||void 0===t?void 0:t.$id)?(0,d.jsx)(A,(0,i.Z)({},e)):(0,d.jsx)(p,(0,i.Z)({},e))}},28121:function(e,t,n){n.d(t,{Z:function(){return u}});n(72791);var i=n(5289),a=n(65661),o=n(39157),r=n(51691),l=n(97123),s=n(24518),c=n(80184);function u(e){var t=e.id,n=e.open,u=e.onOk,d=e.onCancel,p=e.title,A=e.text;return(0,c.jsxs)(i.Z,{title:p||"Logged Out",open:n,onCancel:d,children:[(0,c.jsx)(a.Z,{id:"delete-modal-title",children:"Confirm Delete"}),(0,c.jsx)(o.Z,{children:(0,c.jsx)(r.Z,{children:A})}),(0,c.jsxs)(l.Z,{children:[(0,c.jsx)(s.Z,{onClick:function(){return d(t)},children:"Cancel"},"cancel"),",",(0,c.jsx)(s.Z,{type:"primary",onClick:function(){return u(t)},children:"Confirm"},"submit"),","]})]})}},60142:function(e,t,n){n.d(t,{P:function(){return a},l:function(){return o}});var i=n(80184);function a(e){var t=new Date(e.value);return(0,i.jsx)("span",{children:t.toLocaleString()})}function o(e){for(var t=e.value,n=["","K","M","G","T","P","E","Z","Y"],a=0;t>=1024;)t/=1024,a+=1;return(0,i.jsx)("span",{children:t>0?t.toFixed(2)+" "+n[a]:t+" "+n[a]})}},72115:function(e,t,n){n.d(t,{Z:function(){return u}});n(72791);var i=n(20068),a=n(13400),o=n(87569),r=n(14665),l=n(4152),s=n(2216),c=n(80184);function u(e){var t=e.visibility,n=e.published,u=e.setShowSharingModal,d=void 0===u?function(){}:u,p=e.disabled,A=void 0!==p&&p,h=n&&!A?"success":"gray",v="";return 3===t?v="Publicly accessible":2===t?v="Anyone with the link can access":1===t?v="Accessible by anyone in your organization":0===t&&(v="Only selected users and you can access"),n||(v="Not published"),(0,c.jsx)(i.Z,{title:v,children:(0,c.jsxs)(a.Z,{onClick:function(){return d(!0)},sx:{padding:"0px"},disabled:A,children:[3===t&&(0,c.jsx)(o.Z,{color:h,fontSize:"small"}),2===t&&(0,c.jsx)(r.Z,{color:h,fontSize:"small"}),1===t&&(0,c.jsx)(l.Z,{color:h,fontSize:"small"}),0===t&&(0,c.jsx)(s.Z,{color:h,fontSize:"small"})]})})}},8414:function(e,t,n){n.r(t),n.d(t,{default:function(){return Aa}});var i=n(1413),a=n(29439),o=n(72791),r=n(7077),l=n(57689),s=n(31752),c=n(48550),u=n(80184);function d(e){var t=e.appName,n=e.setAppName,i=(0,o.useState)(!1),r=(0,a.Z)(i,2),l=r[0],d=r[1];return(0,u.jsx)("div",{children:l?(0,u.jsx)(c.Z,{id:"standard-basic",label:"App Name",variant:"standard",value:t,onChange:function(e){return n(e.target.value)},sx:{width:"100%"},onBlur:function(){d(!1),n(t||"Untitled")},onKeyDown:function(e){"Enter"===e.key&&(d(!1),n(t||"Untitled"))},inputRef:function(e){return e&&e.focus()},focused:l,required:!0}):(0,u.jsxs)("h1",{onClick:function(){return d(!0)},style:{fontSize:"20px",margin:"5px 0",textAlign:"left"},children:[t," ",(0,u.jsx)(s.Z,{style:{fontSize:"12px",color:"#666"}})]})})}var p=n(93433),A=n(12705),h=n(56030),v=n(58518),f=n(5289),m=n(65661),x=n(39157),g=n(64554),b=n(68096),Z=n(58406),j=n(23786),y=n(39281),C=n(13400),I=n(79836),N=n(53382),k=n(35855),w=n(53994),S=n(97123),M=n(24518),P=n(13239),T=n(97750),R={width:"100%",maxWidth:500,margin:"auto","& .MuiButtonBase-root":{"&.MuiButton-root":{textTransform:"none"}}};function O(e){var t,n,i=e.show,l=e.setShow,s=e.app,d=e.setIsPublished,O=e.setAppVisibility,D=void 0===O?null:O,G=e.setReadAccessibleBy,W=void 0===G?null:G,z=e.setWriteAccessibleBy,E=void 0===z?null:z,L=e.editSharing,V=void 0!==L&&L,B=(0,o.useState)(!1),Y=(0,a.Z)(B,2),U=Y[0],H=Y[1],X=(0,o.useState)(!1),J=(0,a.Z)(X,2),q=J[0],F=J[1],K=(0,o.useState)(null===s||void 0===s?void 0:s.visibility),Q=(0,a.Z)(K,2),_=Q[0],$=Q[1],ee=(0,o.useState)(""),te=(0,a.Z)(ee,2),ne=te[0],ie=te[1],ae=(0,o.useState)(((null===s||void 0===s||null===(t=s.read_accessible_by)||void 0===t?void 0:t.map((function(e){return{email:e,access:0}})))||[]).concat(null===s||void 0===s||null===(n=s.write_accessible_by)||void 0===n?void 0:n.map((function(e){return{email:e,access:1}})))||[]),oe=(0,a.Z)(ae,2),re=oe[0],le=oe[1],se=(0,h.sJ)(A.Dg),ce=[{label:"Viewer",value:0,description:"Users can view the app"},{label:"Collaborator",value:1,description:"Users can collaborate on the app"}],ue=[];(se.CAN_PUBLISH_PUBLIC_APPS||3===(null===s||void 0===s?void 0:s.visibility))&&ue.push({label:"Public",value:3,description:"Anyone can access this app"}),(se.CAN_PUBLISH_UNLISTED_APPS||2===(null===s||void 0===s?void 0:s.visibility))&&ue.push({label:"Unlisted",value:2,description:"Anyone with the app's published url can access this app"}),(se.CAN_PUBLISH_ORG_APPS||1===(null===s||void 0===s?void 0:s.visibility))&&ue.push({label:"Organization",value:1,description:"Only members of your organization can access this app"}),(se.CAN_PUBLISH_PRIVATE_APPS||0===(null===s||void 0===s?void 0:s.visibility))&&ue.push({label:"Private",value:0,description:"Only you and the selected users can access this app"});return(0,u.jsxs)(f.Z,{open:i,onClose:function(){return l(!1)},sx:R,children:[(0,u.jsx)(m.Z,{children:V?"App Sharing":"Publish App"}),(0,u.jsxs)(x.Z,{children:[q&&(0,u.jsxs)("p",{children:["App ",V?"saved":"published"," successfully!"]}),!q&&(0,u.jsxs)(g.Z,{children:[(0,u.jsx)("p",{children:"Choose a visiblity level for this app. This setting can be changed later."}),(0,u.jsx)("p",{}),(0,u.jsx)(b.Z,{fullWidth:!0,children:(0,u.jsx)(Z.Z,{id:"visibility",value:_,onChange:function(e){return $(e.target.value)},size:"small",renderValue:function(e){var t;return null===(t=ue.find((function(t){return t.value===e})))||void 0===t?void 0:t.label},children:ue.map((function(e){return(0,u.jsxs)(j.Z,{value:e.value,children:[e.label,"\xa0",(0,u.jsx)("br",{}),(0,u.jsx)("small",{children:e.description})]},e.value)}))})}),(0,u.jsx)("p",{}),(0,u.jsxs)(y.Z,{sx:{".MuiTableCell-root":{padding:"2px"},".MuiTable-root":{marginTop:"10px"}},children:[(0,u.jsx)("p",{children:"Users with access:"}),(0,u.jsx)(c.Z,{label:"Invite by email",value:ne,onChange:function(e){return ie(e.target.value)},size:"small",disabled:void 0===ue.find((function(e){return 0===e.value}))}),"\xa0",(0,u.jsx)(C.Z,{variant:"contained",onClick:function(){if(ne.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)){var e=(0,p.Z)(re);e.push({email:ne,access:0}),le(e),ie("")}else(0,v.yv)("Invalid email address",{variant:"error"})},children:(0,u.jsx)(T.Z,{})}),(0,u.jsx)(I.Z,{children:(0,u.jsx)(N.Z,{children:re.map((function(e,t){return(0,u.jsxs)(k.Z,{children:[(0,u.jsx)(w.Z,{children:e.email}),(0,u.jsx)(w.Z,{children:(0,u.jsx)(b.Z,{children:(0,u.jsx)(Z.Z,{id:"access-permission",size:"small",value:e.access,onChange:function(e){var n=(0,p.Z)(re);n[t].access=e.target.value,le(n)},renderValue:function(e){return 0===e?"Viewer":"Collaborator"},variant:"standard",children:ce.map((function(e){return(0,u.jsxs)(j.Z,{value:e.value,children:[e.label,"\xa0",(0,u.jsx)("br",{}),(0,u.jsx)("small",{children:e.description})]},e.value)}))})})})]},t)}))})})]})]})]}),(0,u.jsxs)(S.Z,{children:[(0,u.jsx)(M.Z,{onClick:function(){return l(!1)},children:"Cancel"}),(0,u.jsx)(M.Z,{onClick:function(){if(q)return l(!1),void F(!1);H(!0),(0,r.o)().post("/api/apps/".concat(s.uuid,"/publish"),{visibility:_,read_accessible_by:re.filter((function(e){return 0===e.access})).map((function(e){return e.email})),write_accessible_by:re.filter((function(e){return 1===e.access})).map((function(e){return e.email}))}).then((function(){d(!0),F(!0),D&&D(_),W&&W(re.filter((function(e){return 0===e.access}))),E&&E(re.filter((function(e){return 1===e.access})))})).catch((function(e){var t,n;(0,v.yv)((null===(t=e.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.message)||"Error publishing app",{variant:"error"})})).finally((function(){H(!1)}))},variant:"contained",children:U?(0,u.jsx)(P.Z,{}):q?(0,u.jsx)("a",{href:"/app/".concat(s.published_uuid),target:"_blank",rel:"noreferrer",style:{color:"white",textDecoration:"none"},children:"View Published App"}):V?"Save App":"Publish App"})]})]})}function D(e){var t=e.show,n=e.setShow,i=e.app,a=e.setIsPublished,o=e.setAppVisibility,r=e.setReadAccessibleBy,l=e.setWriteAccessibleBy;return(0,u.jsx)(O,{show:t,setShow:n,app:i,setIsPublished:a,setAppVisibility:o,setReadAccessibleBy:r,setWriteAccessibleBy:l})}function G(e){var t=e.show,n=e.setShow,i=e.app,a=e.setIsPublished,o=e.setAppVisibility;return(0,u.jsx)(O,{show:t,setShow:n,app:i,setIsPublished:a,setAppVisibility:o,editSharing:!0})}function W(e){var t=e.show,n=e.setShow,i=e.app,l=e.setIsPublished,s=(0,o.useState)(!1),c=(0,a.Z)(s,2),d=c[0],p=c[1],A=(0,o.useState)(!1),h=(0,a.Z)(A,2),g=h[0],b=h[1];return(0,u.jsxs)(f.Z,{open:t,onClose:function(){return n(!1)},sx:R,children:[(0,u.jsx)(m.Z,{children:"Unpublish App"}),(0,u.jsxs)(x.Z,{children:[g&&(0,u.jsx)("p",{children:"App unpublished successfully!"}),!g&&(0,u.jsx)("p",{children:"Are you sure want to unpublish the app? This will make the app unaccessible to anyone it was already shared with."})]}),(0,u.jsxs)(S.Z,{children:[(0,u.jsx)(M.Z,{onClick:function(){return n(!1)},children:"Cancel"}),(0,u.jsx)(M.Z,{onClick:function(){if(g)return n(!1),void b(!1);p(!0),(0,r.o)().post("/api/apps/".concat(i.uuid,"/unpublish")).then((function(){l(!1),b(!0)})).catch((function(e){var t,n;(0,v.yv)((null===(t=e.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.message)||"Error unpublishing app",{variant:"error"})})).finally((function(){p(!1)}))},variant:"contained",children:d?(0,u.jsx)(P.Z,{}):g?"Done":"Yes, Unpublish App"})]})]})}var z=n(14058),E=n(99259),L=n(84395),V=n(35527),B=n(53767),Y=n(50533),U=n(20068),H=n(61889),X=n(55196),J=n(41286),q=n(31353),F=n(88161),K=n(17949),Q=n(11600),_=n(84705);function $(e){var t=e.tourRef1,n=e.tourRef2,i=e.tourRef3,r=e.tourRef4,l=e.tourRef5,s=e.tourRef6,c=e.page,d=[{title:"Welcome to Promptly",description:"Here is a quick how-to video to get started with app builder. With Promptly, you can build AI apps and chatbots by chaining processors together. Platform documentation can be found at https://docs.trypromptly.com",cover:(0,u.jsx)("video",{width:"100%",height:"100%",autoPlay:!0,loop:!0,muted:!0,children:(0,u.jsx)("source",{src:"https://storage.googleapis.com/trypromptly-static/static/images/promptly-app-builder-demo.mp4",type:"video/mp4"})})},{title:"Name your App, preview and publish externally",description:"You can rename your app, preview it and publish it externally from this bar.",target:function(){return t.current}},{title:"App Input",description:"This is where you can define the input to your app. You can add inputs using the Add Fields button. This will be rendered as a form in the published app.",target:function(){return n.current}},{title:"Processor Chain",description:"Processor nodes are the building blocks of your app. You can add multiple processors and connect them to form a chain. Each processor is typically a LLM or an API call. For example, you can add Open AI's ChatGPT as a processor, configure it and connect its output to DALL-E in the next processor.",target:function(){return i.current}},{title:"App Output",description:"This is where you can define the output of your app. You can use Template Variables and insert user input data or the output from any processor as input in processors below it. Template variables can be used in the output of the app as well",target:function(){return r.current}},{title:"Save your App",description:"Click this to save your app before previewing. You can also publish it externally from the top bar. Make sure to add your Open AI or DreamStudio API keys in the settings page before running your app.",target:function(){return l.current}},{title:"App Menu",description:"Use this menu to navigate between different pages of the app like editor, preview, settings, integrations etc.",target:function(){return s.current}}],p=(0,Q.Z)(["app-builder-tour","app-template-tour"]),A=(0,a.Z)(p,2),h=A[0],v=A[1],f=(0,o.useState)((!c||"editor"===c)&&void 0===h["app-builder-tour"]||"template"===c&&void 0===h["app-template-tour"]),m=(0,a.Z)(f,2),x=m[0],g=m[1];return(0,u.jsx)(_.Z,{open:x,onClose:function(){g(!1),!c||"editor"===c&&v("app-builder-tour","1"),"template"===c&&v("app-template-tour","1")},steps:c&&"editor"!==c?[d[0],d[1],d[6]]:d,style:{width:"100%"}})}var ee=n(72115),te=n(79834),ne=n(76278),ie=n(57064),ae=n(49900),oe=n(90493);function re(e){var t=e.menuItems,n=e.selectedMenuItem,i=e.setSelectedMenuItem,a=e.tourRef;return(0,h.sJ)(A.lo)?(0,u.jsx)(b.Z,{sx:{m:1,width:"100%",margin:0},variant:"filled",children:(0,u.jsx)(Z.Z,{defaultValue:"",id:"grouped-select",label:"App Menu",value:n,ref:a,children:t.map((function(e){return e.children&&e.children.length>0?[(0,u.jsx)(te.Z,{children:e.name},e.name)].concat((0,p.Z)(e.children.map((function(e){return(0,u.jsx)(j.Z,{value:e.value,children:(0,u.jsxs)(ne.Z,{onClick:function(t){return i(e.value)},children:[(0,u.jsx)(ie.Z,{children:e.icon}),(0,u.jsx)(ae.Z,{primary:e.name})]})},e.name)})))):(0,u.jsx)(j.Z,{value:e.value,children:(0,u.jsxs)(ne.Z,{onClick:function(t){return i(e.value)},children:[(0,u.jsx)(ie.Z,{children:e.icon}),(0,u.jsx)(ae.Z,{primary:e.name})]})},e.value)}))})}):(0,u.jsx)(oe.Z,{sx:{width:"100%",maxWidth:360,bgcolor:"background.paper"},component:"nav",ref:a,children:t.map((function(e){return e.children&&e.children.length>0?[(0,u.jsxs)(ne.Z,{disableRipple:!0,disableTouchRipple:!0,sx:{"&.MuiButtonBase-root:hover":{backgroundColor:"transparent"}},children:[(0,u.jsx)(ie.Z,{children:e.icon}),(0,u.jsx)(ae.Z,{primary:e.name})]},e.name),(0,u.jsx)(oe.Z,{component:"div",children:e.children.map((function(e){return(0,u.jsxs)(ne.Z,{sx:{pl:4},selected:n===e.value,onClick:function(t){return i(e.value)},children:[(0,u.jsx)(ie.Z,{children:e.icon}),(0,u.jsx)(ae.Z,{primary:e.name})]},e.name)}))},"".concat(e.name,"-children"))]:(0,u.jsxs)(ne.Z,{selected:n===e.value,onClick:function(t){return i(e.value)},children:[(0,u.jsx)(ie.Z,{children:e.icon}),(0,u.jsx)(ae.Z,{primary:e.name})]},e.name)}))})}var le=n(39504),se=n(89673),ce=n(55818),ue=n(20890),de=n(3721),pe=n(27247),Ae=n(81131),he=n(26577),ve=n(57697),fe=n(41942),me=n(6748),xe=n(38996),ge=n(15671),be=n(43144),Ze=n(60136),je=n(29388),ye=n(11752),Ce=n(61120),Ie=n(25224),Ne=n(34588),ke=n(53527),we=n(33839),Se=n(65528),Me=n(61215),Pe=n(29473),Te=n(64937),Re=n(16868),Oe=n(59070),De=n(61577),Ge=n(3732),We=n(76010),ze=n(31759),Ee=n(60574),Le=n.n(Ee),Ve=n(45523),Be=n(81918),Ye=n(4942),Ue=n(89689),He=n(54140),Xe=n(54164),Je=o.createContext(null);function qe(e){var t=e.children,n=e.className,i=e.onClick,a=e.title,r=(0,o.useRef)(null),l=o.useContext(Je);if(null===l)throw new Error("DropDownItem must be used within a DropDown");var s=l.registerItem;return(0,o.useEffect)((function(){r&&r.current&&s(r)}),[r,s]),(0,u.jsx)("button",{className:n,onClick:i,ref:r,title:a,type:"button",children:t})}function Fe(e){var t=e.children,n=e.dropDownRef,i=e.onClose,r=(0,o.useState)(),l=(0,a.Z)(r,2),s=l[0],c=l[1],d=(0,o.useState)(),A=(0,a.Z)(d,2),h=A[0],v=A[1],f=(0,o.useCallback)((function(e){c((function(t){return t?[].concat((0,p.Z)(t),[e]):[e]}))}),[c]),m=(0,o.useMemo)((function(){return{registerItem:f}}),[f]);return(0,o.useEffect)((function(){s&&!h&&v(s[0]),h&&h.current&&h.current.focus()}),[s,h]),(0,u.jsx)(Je.Provider,{value:m,children:(0,u.jsx)("div",{className:"dropdown",ref:n,onKeyDown:function(e){if(s){var t=e.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(t)&&e.preventDefault(),"Escape"===t||"Tab"===t?i():"ArrowUp"===t?v((function(e){if(!e)return s[0];var t=s.indexOf(e)-1;return s[-1===t?s.length-1:t]})):"ArrowDown"===t&&v((function(e){return e?s[s.indexOf(e)+1]:s[0]}))}},children:t})})}function Ke(e){var t=e.disabled,n=void 0!==t&&t,i=e.buttonLabel,r=e.buttonAriaLabel,l=e.buttonClassName,s=e.buttonIconClassName,c=e.children,d=e.stopCloseOnClickSelf,p=(0,o.useRef)(null),A=(0,o.useRef)(null),h=(0,o.useState)(!1),v=(0,a.Z)(h,2),f=v[0],m=v[1];return(0,o.useEffect)((function(){var e=A.current,t=p.current;if(f&&null!==e&&null!==t){var n=e.getBoundingClientRect(),i=n.top,a=n.left;t.style.top="".concat(i+40,"px"),t.style.left="".concat(Math.min(a,window.innerWidth-t.offsetWidth-20),"px")}}),[p,A,f]),(0,o.useEffect)((function(){var e=A.current;if(null!==e&&f){var t=function(t){var n=t.target;d&&p.current&&p.current.contains(n)||e.contains(n)||m(!1)};return document.addEventListener("click",t),function(){document.removeEventListener("click",t)}}}),[p,A,f,d]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{disabled:n,"aria-label":r||i,className:l,onClick:function(){return m(!f)},ref:A,children:[s&&(0,u.jsx)("span",{className:s}),i&&(0,u.jsx)("span",{className:"text dropdown-button-text",children:i}),(0,u.jsx)("i",{className:"chevron-down"})]}),f&&(0,Xe.createPortal)((0,u.jsx)(Fe,{dropDownRef:p,onClose:function(){m(!1),A&&A.current&&A.current.focus()},children:c}),document.body)]})}var Qe=n(45987);function _e(e){var t=e.label,n=e.value,i=e.onChange,a=e.placeholder,o=void 0===a?"":a,r=e["data-test-id"];return(0,u.jsxs)("div",{className:"Input__wrapper",children:[(0,u.jsx)("label",{className:"Input__label",children:t}),(0,u.jsx)("input",{type:"text",className:"Input__input",placeholder:o,value:n,onChange:function(e){i(e.target.value)},"data-test-id":r})]})}var $e=["color","children","onChange","disabled","stopCloseOnClickSelf"],et=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],tt=214;function nt(e){var t=e.color,n=e.children,r=e.onChange,l=e.disabled,s=void 0!==l&&l,c=e.stopCloseOnClickSelf,d=void 0===c||c,p=(0,Qe.Z)(e,$e),A=(0,o.useState)(ct("hex",t)),h=(0,a.Z)(A,2),v=h[0],f=h[1],m=(0,o.useState)(t),x=(0,a.Z)(m,2),g=x[0],b=x[1],Z=(0,o.useRef)(null),j=(0,o.useMemo)((function(){return{x:v.hsv.s/100*tt,y:(100-v.hsv.v)/100*150}}),[v.hsv.s,v.hsv.v]),y=(0,o.useMemo)((function(){return{x:v.hsv.h/360*tt}}),[v.hsv]);return(0,o.useEffect)((function(){null!==Z.current&&r&&(r(v.hex),b(v.hex))}),[v,r]),(0,o.useEffect)((function(){if(void 0!==t){var e=ct("hex",t);f(e),b(e.hex)}}),[t]),(0,u.jsxs)(Ke,(0,i.Z)((0,i.Z)({},p),{},{disabled:s,stopCloseOnClickSelf:d,children:[(0,u.jsxs)("div",{className:"color-picker-wrapper",style:{width:tt},ref:Z,children:[(0,u.jsx)(_e,{label:"Hex",onChange:function(e){if(b(e),/^#[0-9A-Fa-f]{6}$/i.test(e)){var t=ct("hex",e);f(t)}},value:g}),(0,u.jsx)("div",{className:"color-picker-basic-color",children:et.map((function(e){return(0,u.jsx)("button",{className:e===v.hex?" active":"",style:{backgroundColor:e},onClick:function(){b(e),f(ct("hex",e))}},e)}))}),(0,u.jsx)(it,{className:"color-picker-saturation",style:{backgroundColor:"hsl(".concat(v.hsv.h,", 100%, 50%)")},onChange:function(e){var t=e.x,n=e.y,a=ct("hsv",(0,i.Z)((0,i.Z)({},v.hsv),{},{s:t/tt*100,v:100-n/150*100}));f(a),b(a.hex)},children:(0,u.jsx)("div",{className:"color-picker-saturation_cursor",style:{backgroundColor:v.hex,left:j.x,top:j.y}})}),(0,u.jsx)(it,{className:"color-picker-hue",onChange:function(e){var t=e.x,n=ct("hsv",(0,i.Z)((0,i.Z)({},v.hsv),{},{h:t/tt*360}));f(n),b(n.hex)},children:(0,u.jsx)("div",{className:"color-picker-hue_cursor",style:{backgroundColor:"hsl(".concat(v.hsv.h,", 100%, 50%)"),left:y.x}})}),(0,u.jsx)("div",{className:"color-picker-color",style:{backgroundColor:v.hex}})]}),n]}))}function it(e){var t=e.className,n=e.style,i=e.onChange,a=e.children,r=(0,o.useRef)(null),l=function(e){if(r.current){var t=r.current.getBoundingClientRect(),n=t.width,a=t.height,o=t.left,l=t.top,s=at(e.clientX-o,n,0),c=at(e.clientY-l,a,0);i({x:s,y:c})}};return(0,u.jsx)("div",{ref:r,className:t,style:n,onMouseDown:function(e){if(0===e.button){l(e);var t=function(e){l(e)};document.addEventListener("mousemove",t,!1),document.addEventListener("mouseup",(function e(n){document.removeEventListener("mousemove",t,!1),document.removeEventListener("mouseup",e,!1),l(n)}),!1)}},children:a})}function at(e,t,n){return e>t?t:e<n?n:e}function ot(e){if(!e.startsWith("#")){var t=document.createElement("canvas").getContext("2d");if(!t)throw new Error("2d context not supported or canvas already initialized");return t.fillStyle=e,t.fillStyle}return 4===e.length||5===e.length?e=e.split("").map((function(e,t){return t?e+e:"#"})).join(""):7===e.length||9===e.length?e:"#000000"}function rt(e){var t=(e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,n,i){return"#"+t+t+n+n+i+i})).substring(1).match(/.{2}/g)||[]).map((function(e){return parseInt(e,16)}));return{b:t[2],g:t[1],r:t[0]}}function lt(e){var t=e.r,n=e.g,i=e.b;t/=255,n/=255,i/=255;var a=Math.max(t,n,i),o=a-Math.min(t,n,i);return{h:o?60*(a===t?(n-i)/o+(n<i?6:0):a===n?2+(i-t)/o:4+(t-n)/o):0,s:a?o/a*100:0,v:100*a}}function st(e){var t=e.b,n=e.g;return"#"+[e.r,n,t].map((function(e){return e.toString(16).padStart(2,"0")})).join("")}function ct(e,t){var n=ot("#121212"),i=rt(n),a=lt(i);if("hex"===e)a=lt(i=rt(n=ot(t)));else if("rgb"===e){n=st(i=t),a=lt(i)}else if("hsv"===e){n=st(i=function(e){var t=e.h,n=e.s,i=e.v,a=~~(t/60),o=t/60-a,r=(i/=100)*(1-(n/=100)),l=i*(1-n*o),s=i*(1-n*(1-o)),c=a%6,u=Math.round(255*[i,l,r,r,s,i][c]),d=Math.round(255*[s,i,i,l,r,r][c]);return{b:Math.round(255*[r,r,s,i,i,l][c]),g:d,r:u}}(a=t))}return{hex:n,hsv:a,rgb:i}}var ut=new Set(["paragraph","quote","code","h1","h2","ul","ol"]),dt={code:"Code Block",h1:"Large Heading",h2:"Small Heading",h3:"Heading",h4:"Heading",h5:"Heading",ol:"Numbered List",paragraph:"Normal",quote:"Quote",ul:"Bulleted List"},pt=[["Arial","Arial"],["Courier New","Courier New"],["Georgia","Georgia"],["Lato","Lato"],["Times New Roman","Times New Roman"],["Trebuchet MS","Trebuchet MS"],["Verdana","Verdana"]],At=[["10px","10px"],["11px","11px"],["12px","12px"],["13px","13px"],["14px","14px"],["15px","15px"],["16px","16px"],["17px","17px"],["18px","18px"],["19px","19px"],["20px","20px"]];function ht(){return(0,u.jsx)("div",{className:"divider"})}function vt(e,t){null===t?(e.style.opacity="0",e.style.top="-1000px",e.style.left="-1000px"):(e.style.opacity="1",e.style.top="".concat(t.top+t.height+window.pageYOffset+10,"px"),e.style.left="".concat(t.left+window.pageXOffset-e.offsetWidth/2+t.width/2,"px"))}function ft(e){var t=e.editor,n=(0,o.useRef)(null),i=(0,o.useRef)(null),r=(0,o.useRef)(!1),l=(0,o.useState)(""),s=(0,a.Z)(l,2),c=s[0],d=s[1],p=(0,o.useState)(!1),A=(0,a.Z)(p,2),h=A[0],v=A[1],f=(0,o.useState)(null),m=(0,a.Z)(f,2),x=m[0],g=m[1],b=(0,o.useCallback)((function(){var e=(0,Ve.$getSelection)();if((0,Ve.$isRangeSelection)(e)){var i=xt(e),a=i.getParent();(0,De.$isLinkNode)(a)?d(a.getURL()):(0,De.$isLinkNode)(i)?d(i.getURL()):d("")}var o=n.current,l=window.getSelection(),s=document.activeElement;if(null!==o){var c=t.getRootElement();if(null!==e&&!l.isCollapsed&&null!==c&&c.contains(l.anchorNode)){var u,p=l.getRangeAt(0);if(l.anchorNode===c){for(var A=c;null!=A.firstElementChild;)A=A.firstElementChild;u=A.getBoundingClientRect()}else u=p.getBoundingClientRect();r.current||vt(o,u),g(e)}else s&&"link-input"===s.className||(vt(o,null),g(null),v(!1),d(""));return!0}}),[t]);return(0,o.useEffect)((function(){return(0,He.mergeRegister)(t.registerUpdateListener((function(e){e.editorState.read((function(){b()}))})),t.registerCommand(Ve.SELECTION_CHANGE_COMMAND,(function(){return b(),!0}),1))}),[t,b]),(0,o.useEffect)((function(){t.getEditorState().read((function(){b()}))}),[t,b]),(0,o.useEffect)((function(){h&&i.current&&i.current.focus()}),[h]),(0,u.jsx)("div",{ref:n,className:"link-editor",children:h?(0,u.jsx)("input",{ref:i,className:"link-input",value:c,onChange:function(e){d(e.target.value)},onKeyDown:function(e){"Enter"===e.key?(e.preventDefault(),null!==x&&(""!==c&&t.dispatchCommand(De.TOGGLE_LINK_COMMAND,c),v(!1))):"Escape"===e.key&&(e.preventDefault(),v(!1))}}):(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("div",{className:"link-input",children:[(0,u.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:c}),(0,u.jsx)("div",{className:"link-edit",role:"button",tabIndex:0,onMouseDown:function(e){return e.preventDefault()},onClick:function(){v(!0)}})]})})})}function mt(e){var t=e.onChange,n=e.className,i=e.options,a=e.value;return(0,u.jsxs)("select",{className:n,onChange:t,value:a,children:[(0,u.jsx)("option",{hidden:!0,value:""}),i.map((function(e){return(0,u.jsx)("option",{value:e,children:e},e)}))]})}function xt(e){var t=e.anchor,n=e.focus,i=e.anchor.getNode(),a=e.focus.getNode();return i===a?i:e.isBackward()?(0,Ue.$isAtNodeEnd)(n)?i:a:(0,Ue.$isAtNodeEnd)(t)?a:i}function gt(e){var t=e.editor,n=e.blockType,i=e.toolbarRef,a=e.setShowBlockOptionsDropDown,r=(0,o.useRef)(null);(0,o.useEffect)((function(){var e=i.current,t=r.current;if(null!==e&&null!==t){var n=e.getBoundingClientRect(),a=n.top,o=n.left;t.style.top="".concat(a+40,"px"),t.style.left="".concat(o,"px")}}),[r,i]),(0,o.useEffect)((function(){var e=r.current,t=i.current;if(null!==e&&null!==t){var n=function(n){var i=n.target;e.contains(i)||t.contains(i)||a(!1)};return document.addEventListener("click",n),function(){document.removeEventListener("click",n)}}}),[r,a,i]);return(0,u.jsxs)("div",{className:"dropdown",ref:r,children:[(0,u.jsxs)("button",{className:"item",onClick:function(){"paragraph"!==n&&t.update((function(){var e=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(e)&&(0,Ue.$wrapNodes)(e,(function(){return(0,Ve.$createParagraphNode)()}))})),a(!1)},children:[(0,u.jsx)("span",{className:"icon paragraph"}),(0,u.jsx)("span",{className:"text",children:"Normal"}),"paragraph"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"h1"!==n&&t.update((function(){var e=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(e)&&(0,Ue.$wrapNodes)(e,(function(){return(0,Pe.$createHeadingNode)("h1")}))})),a(!1)},children:[(0,u.jsx)("span",{className:"icon large-heading"}),(0,u.jsx)("span",{className:"text",children:"Large Heading"}),"h1"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"h2"!==n&&t.update((function(){var e=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(e)&&(0,Ue.$wrapNodes)(e,(function(){return(0,Pe.$createHeadingNode)("h2")}))})),a(!1)},children:[(0,u.jsx)("span",{className:"icon small-heading"}),(0,u.jsx)("span",{className:"text",children:"Small Heading"}),"h2"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"ul"!==n?t.dispatchCommand(Re.INSERT_UNORDERED_LIST_COMMAND):t.dispatchCommand(Re.REMOVE_LIST_COMMAND),a(!1)},children:[(0,u.jsx)("span",{className:"icon bullet-list"}),(0,u.jsx)("span",{className:"text",children:"Bullet List"}),"ul"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"ol"!==n?t.dispatchCommand(Re.INSERT_ORDERED_LIST_COMMAND):t.dispatchCommand(Re.REMOVE_LIST_COMMAND),a(!1)},children:[(0,u.jsx)("span",{className:"icon numbered-list"}),(0,u.jsx)("span",{className:"text",children:"Numbered List"}),"ol"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"quote"!==n&&t.update((function(){var e=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(e)&&(0,Ue.$wrapNodes)(e,(function(){return(0,Pe.$createQuoteNode)()}))})),a(!1)},children:[(0,u.jsx)("span",{className:"icon quote"}),(0,u.jsx)("span",{className:"text",children:"Quote"}),"quote"===n&&(0,u.jsx)("span",{className:"active"})]}),(0,u.jsxs)("button",{className:"item",onClick:function(){"code"!==n&&t.update((function(){var e=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(e)&&(0,Ue.$wrapNodes)(e,(function(){return(0,Oe.$createCodeNode)()}))})),a(!1)},children:[(0,u.jsx)("span",{className:"icon code"}),(0,u.jsx)("span",{className:"text",children:"Code Block"}),"code"===n&&(0,u.jsx)("span",{className:"active"})]})]})}function bt(e){var t=e.editor,n=e.value,i=e.styleProperty,r=e.disabled,l=void 0!==r&&r,s=(0,o.useCallback)((function(e){t.update((function(){var t=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(t)&&(0,Ue.$patchStyleText)(t,(0,Ye.Z)({},i,e))}))}),[t,i]),c="font-family"===i?"Formatting options for font family":"Formatting options for font size";return(0,u.jsx)(Ke,{disabled:l,buttonClassName:"toolbar-item "+i,buttonLabel:n,buttonIconClassName:"font-family"===i?"icon block-type font-family":"",buttonAriaLabel:c,children:("font-family"===i?pt:At).map((function(e){var t,o=(0,a.Z)(e,2),r=o[0],l=o[1];return(0,u.jsx)(qe,{className:"item ".concat((t=n===r,t?"active dropdown-item-active":"")," ").concat("font-size"===i?"fontsize-item":""),onClick:function(){return s(r)},children:(0,u.jsx)("span",{className:"text",children:l})},r)}))})}function Zt(){var e=(0,Me.useLexicalComposerContext)(),t=(0,a.Z)(e,1)[0],n=(0,o.useRef)(null),i=(0,o.useState)("paragraph"),r=(0,a.Z)(i,2),l=r[0],s=r[1],c=(0,o.useState)(null),d=(0,a.Z)(c,2),p=d[0],A=d[1],h=(0,o.useState)(!1),v=(0,a.Z)(h,2),f=v[0],m=v[1],x=(0,o.useState)(""),g=(0,a.Z)(x,2),b=g[0],Z=g[1],j=(0,o.useState)(!1),y=(0,a.Z)(j,2),C=y[0],I=y[1],N=(0,o.useState)(!1),k=(0,a.Z)(N,2),w=k[0],S=k[1],M=(0,o.useState)(!1),P=(0,a.Z)(M,2),T=P[0],R=P[1],O=(0,o.useState)(!1),D=(0,a.Z)(O,2),G=D[0],W=D[1],z=(0,o.useState)(!1),E=(0,a.Z)(z,2),L=E[0],V=E[1],B=(0,o.useState)(!1),Y=(0,a.Z)(B,2),U=Y[0],H=Y[1],X=(0,o.useState)(!1),J=(0,a.Z)(X,2),q=J[0],F=J[1],K=(0,o.useState)("Lato"),Q=(0,a.Z)(K,2),_=Q[0],$=Q[1],ee=(0,o.useState)("15px"),te=(0,a.Z)(ee,2),ne=te[0],ie=te[1],ae=(0,o.useState)("#000"),oe=(0,a.Z)(ae,2),re=oe[0],le=oe[1],se=t.isEditable(),ce=(0,o.useCallback)((function(){var e=(0,Ve.$getSelection)();if((0,Ve.$isRangeSelection)(e)){var n=e.anchor.getNode(),i="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),a=i.getKey();if(null!==t.getElementByKey(a))if(A(a),(0,Re.$isListNode)(i)){var o=(0,He.$getNearestNodeOfType)(n,Re.ListNode),r=o?o.getTag():i.getTag();s(r)}else{var l=(0,Pe.$isHeadingNode)(i)?i.getTag():i.getType();s(l),(0,Oe.$isCodeNode)(i)&&Z(i.getLanguage()||(0,Oe.getDefaultCodeLanguage)())}R(e.hasFormat("bold")),W(e.hasFormat("italic")),V(e.hasFormat("underline")),H(e.hasFormat("strikethrough")),F(e.hasFormat("code")),I((0,Ue.$isParentElementRTL)(e)),ie((0,Ue.$getSelectionStyleValueForProperty)(e,"font-size","15px")),$((0,Ue.$getSelectionStyleValueForProperty)(e,"font-family","Lato")),le((0,Ue.$getSelectionStyleValueForProperty)(e,"color","#000"));var c=xt(e),u=c.getParent();(0,De.$isLinkNode)(u)||(0,De.$isLinkNode)(c)?S(!0):S(!1)}}),[t]);(0,o.useEffect)((function(){return(0,He.mergeRegister)(t.registerUpdateListener((function(e){e.editorState.read((function(){ce()}))})),t.registerCommand(Ve.SELECTION_CHANGE_COMMAND,(function(e,t){return ce(),!1}),1))}),[t,ce]);var ue=(0,o.useCallback)((function(e){t.update((function(){var t=(0,Ve.$getSelection)();(0,Ve.$isRangeSelection)(t)&&(0,Ue.$patchStyleText)(t,e)}))}),[t]),de=(0,o.useMemo)((function(){return(0,Oe.getCodeLanguages)()}),[]),pe=(0,o.useCallback)((function(e){t.update((function(){if(null!==p){var t=(0,Ve.$getNodeByKey)(p);(0,Oe.$isCodeNode)(t)&&t.setLanguage(e.target.value)}}))}),[t,p]),Ae=(0,o.useCallback)((function(){w?t.dispatchCommand(De.TOGGLE_LINK_COMMAND,null):t.dispatchCommand(De.TOGGLE_LINK_COMMAND,"https://")}),[t,w]),he=(0,o.useCallback)((function(e){ue({color:e})}),[ue]);return(0,u.jsxs)("div",{className:"toolbar",ref:n,children:[ut.has(l)&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{className:"toolbar-item block-controls",onClick:function(){return m(!f)},"aria-label":"Formatting Options",children:[(0,u.jsx)("span",{className:"icon block-type "+l}),(0,u.jsx)("span",{className:"text",children:dt[l]}),(0,u.jsx)("i",{className:"chevron-down"})]}),f&&(0,Xe.createPortal)((0,u.jsx)(gt,{editor:t,blockType:l,toolbarRef:n,setShowBlockOptionsDropDown:m}),document.body),(0,u.jsx)(ht,{})]}),"code"===l?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(mt,{className:"toolbar-item code-language",onChange:pe,options:de,value:b}),(0,u.jsx)("i",{className:"chevron-down inside"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bt,{disabled:!se,styleProperty:"font-family",value:_,editor:t}),(0,u.jsx)(bt,{disabled:!se,styleProperty:"font-size",value:ne,editor:t}),(0,u.jsx)(ht,{}),(0,u.jsx)("button",{onClick:function(){t.dispatchCommand(Ve.FORMAT_TEXT_COMMAND,"bold")},className:"toolbar-item spaced "+(T?"active":""),"aria-label":"Format Bold",children:(0,u.jsx)("i",{className:"format bold"})}),(0,u.jsx)("button",{onClick:function(){t.dispatchCommand(Ve.FORMAT_TEXT_COMMAND,"italic")},className:"toolbar-item spaced "+(G?"active":""),"aria-label":"Format Italics",children:(0,u.jsx)("i",{className:"format italic"})}),(0,u.jsx)("button",{onClick:function(){t.dispatchCommand(Ve.FORMAT_TEXT_COMMAND,"underline")},className:"toolbar-item spaced "+(L?"active":""),"aria-label":"Format Underline",children:(0,u.jsx)("i",{className:"format underline"})}),(0,u.jsx)("button",{onClick:function(){t.dispatchCommand(Ve.FORMAT_TEXT_COMMAND,"strikethrough")},className:"toolbar-item spaced "+(U?"active":""),"aria-label":"Format Strikethrough",children:(0,u.jsx)("i",{className:"format strikethrough"})}),(0,u.jsx)("button",{onClick:function(){t.dispatchCommand(Ve.FORMAT_TEXT_COMMAND,"code")},className:"toolbar-item spaced "+(q?"active":""),"aria-label":"Insert Code",children:(0,u.jsx)("i",{className:"format code"})}),(0,u.jsx)("button",{onClick:Ae,className:"toolbar-item spaced "+(w?"active":""),"aria-label":"Insert Link",children:(0,u.jsx)("i",{className:"format link"})}),(0,u.jsx)(nt,{disabled:!se,buttonClassName:"toolbar-item color-picker",buttonAriaLabel:"Formatting text color",buttonIconClassName:"icon font-color",color:re,onChange:he,title:"text color"}),w&&(0,Xe.createPortal)((0,u.jsx)(ft,{editor:t}),document.body),(0,u.jsx)(ht,{}),(0,u.jsxs)(Ke,{disabled:!se,buttonLabel:"Align",buttonIconClassName:"icon left-align",buttonClassName:"toolbar-item spaced alignment",buttonAriaLabel:"Formatting options for text alignment",children:[(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.FORMAT_ELEMENT_COMMAND,"left")},className:"item",children:[(0,u.jsx)("i",{className:"icon left-align"}),(0,u.jsx)("span",{className:"text",children:"Left Align"})]}),(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.FORMAT_ELEMENT_COMMAND,"center")},className:"item",children:[(0,u.jsx)("i",{className:"icon center-align"}),(0,u.jsx)("span",{className:"text",children:"Center Align"})]}),(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.FORMAT_ELEMENT_COMMAND,"right")},className:"item",children:[(0,u.jsx)("i",{className:"icon right-align"}),(0,u.jsx)("span",{className:"text",children:"Right Align"})]}),(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.FORMAT_ELEMENT_COMMAND,"justify")},className:"item",children:[(0,u.jsx)("i",{className:"icon justify-align"}),(0,u.jsx)("span",{className:"text",children:"Justify Align"})]}),(0,u.jsx)(ht,{}),(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.OUTDENT_CONTENT_COMMAND,void 0)},className:"item",children:[(0,u.jsx)("i",{className:"icon "+(C?"indent":"outdent")}),(0,u.jsx)("span",{className:"text",children:"Outdent"})]}),(0,u.jsxs)(qe,{onClick:function(){t.dispatchCommand(Ve.INDENT_CONTENT_COMMAND,void 0)},className:"item",children:[(0,u.jsx)("i",{className:"icon "+(C?"outdent":"indent")}),(0,u.jsx)("span",{className:"text",children:"Indent"})]})]})]})]})}n(27369);var jt={ltr:"ltr",rtl:"rtl",placeholder:"editor-placeholder",paragraph:"editor-paragraph",quote:"editor-quote",heading:{h1:"editor-heading-h1",h2:"editor-heading-h2",h3:"editor-heading-h3",h4:"editor-heading-h4",h5:"editor-heading-h5"},list:{nested:{listitem:"editor-nested-listitem"},ol:"editor-list-ol",ul:"editor-list-ul",listitem:"editor-listitem"},image:"editor-image",link:"editor-link",text:{bold:"editor-text-bold",italic:"editor-text-italic",overflowed:"editor-text-overflowed",hashtag:"editor-text-hashtag",underline:"editor-text-underline",strikethrough:"editor-text-strikethrough",underlineStrikethrough:"editor-text-underlineStrikethrough",code:"editor-text-code"},code:"editor-code",codeHighlight:{atrule:"editor-tokenAttr",attr:"editor-tokenAttr",boolean:"editor-tokenProperty",builtin:"editor-tokenSelector",cdata:"editor-tokenComment",char:"editor-tokenSelector",class:"editor-tokenFunction","class-name":"editor-tokenFunction",comment:"editor-tokenComment",constant:"editor-tokenProperty",deleted:"editor-tokenProperty",doctype:"editor-tokenComment",entity:"editor-tokenOperator",function:"editor-tokenFunction",important:"editor-tokenVariable",inserted:"editor-tokenSelector",keyword:"editor-tokenAttr",namespace:"editor-tokenVariable",number:"editor-tokenProperty",operator:"editor-tokenOperator",prolog:"editor-tokenComment",property:"editor-tokenProperty",punctuation:"editor-tokenPunctuation",regex:"editor-tokenVariable",selector:"editor-tokenSelector",string:"editor-tokenSelector",symbol:"editor-tokenProperty",tag:"editor-tokenProperty",url:"editor-tokenOperator",variable:"editor-tokenVariable"}},yt=(0,Ve.createCommand)(),Ct=function(e){var t=e.getAttribute("data-lexical-template-variable-text"),n=e.getAttribute("data-lexical-template-variable-data");return t?{node:Nt(t,n)}:null},It=function(e){(0,Ze.Z)(n,e);var t=(0,je.Z)(n);function n(e,i,a,o){var r;return(0,ge.Z)(this,n),(r=t.call(this,a,o)).__text="",r.__data={},r.__text=e,r.__data=i,r}return(0,be.Z)(n,[{key:"exportJSON",value:function(){return(0,i.Z)((0,i.Z)({},(0,ye.Z)((0,Ce.Z)(n.prototype),"exportJSON",this).call(this)),{},{text:this.getText(),data:this.getData()})}},{key:"createDOM",value:function(e,t){var n=document.createElement("div");return n.setAttribute("style","display: inline-block;"),n.setAttribute("data-lexical-template-variable-text",this.__text),n.setAttribute("data-lexical-template-variable-data",this.__data),n}},{key:"updateDOM",value:function(e,t,n){}},{key:"exportDOM",value:function(){var e=document.createElement("div");e.setAttribute("data-lexical-template-variable-text",this.__text),e.setAttribute("data-lexical-template-variable-data",this.__data);var t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}},{key:"getText",value:function(){return this.__text}},{key:"getData",value:function(){return this.__data}},{key:"getTextContent",value:function(e,t){return this.__text}},{key:"decorate",value:function(e,t){return(0,u.jsx)(Be.Z,{label:this.__data,size:"small"})}},{key:"isInline",value:function(){return!0}}],[{key:"getType",value:function(){return"template-variable"}},{key:"clone",value:function(e){return new n(e.__text,e.__data,e.__key)}},{key:"importJSON",value:function(e){return Nt(e.text,e.data)}},{key:"importDOM",value:function(){return{div:function(e){return e.hasAttribute("data-lexical-template-variable-text")?{conversion:Ct,priority:2}:null}}}}]),n}(Ve.DecoratorNode);function Nt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new It(e,t)}function kt(e){var t=e.templateVariables,n=e.text,i=e.setText,r=e.richText,l=function(e,t,n){for(var i=0,o=Object.entries(e);i<o.length;i++){var r=(0,a.Z)(o[i],2),l=r[0],s=r[1];if(t.startsWith(l,n))return[l,s]}return null},s=(0,Me.useLexicalComposerContext)(),c=(0,a.Z)(s,1)[0];return(0,o.useEffect)((function(){if(c&&!c.hasNodes([It]))throw new Error("TemplateVariableNode not registered!");var e=c.registerUpdateListener((function(e){var t=e.editorState;i&&t.read((function(){if(r)i((0,ze.$generateHtmlFromNodes)(c));else{var e=(0,Ve.$getRoot)().getTextContent();i(e)}}))}));if(c.registerCommand(yt,(function(e){return e&&c.update((function(){var t=Nt(e,e);(0,Ve.$insertNodes)([t,(0,Ve.$createTextNode)(" ")])})),!0}),Ve.COMMAND_PRIORITY_EDITOR),e)return e}),[c,n,i,r]),(0,o.useEffect)((function(){c&&c.getEditorState().read((function(){var e=(0,Ve.$getRoot)();""===e.getTextContent()&&c.update((function(){if(!e.isDirty()&&""!==n)if(!r||n&&!n.startsWith("<")){var t=(0,Ve.$createParagraphNode)(),i=(0,Ve.$createTextNode)(n);t.append(i),e.getFirstChild().replace(t)}else{var a=(new DOMParser).parseFromString(n,"text/html"),o=(0,ze.$generateNodesFromDOM)(c,a);(0,Ve.$insertNodes)(o)}}))}))}),[n,c,r]),(0,o.useEffect)((function(){c&&""!==n&&Object.keys(t).length>0&&!r&&c.getEditorState().read((function(){setTimeout((function(){c.update((function(){var e,i=(0,Ve.$getRoot)();if(!i.isDirty()){for(var a=(0,Ve.$createParagraphNode)(),o=[],r=n,s=0;s<(null===(c=r)||void 0===c?void 0:c.length);){var c,u=l(t,r,s);u?(s>0&&(o.push((0,Ve.$createTextNode)(r.slice(0,s))),r=r.slice(s),s=0),o.push(Nt(u[0],u[1])),r=r.slice(u[0].length)):s++}(null===(e=r)||void 0===e?void 0:e.length)>0&&o.push((0,Ve.$createTextNode)(r)),a.append.apply(a,o),i.getFirstChild().replace(a),a.select()}}))}),0)}))}),[t,n,c,r]),null}function wt(e){var t=e.editorRef,n=(0,Me.useLexicalComposerContext)(),i=(0,a.Z)(n,1)[0];return(0,o.useLayoutEffect)((function(){return t.current=i,function(){t.current=null}}),[i,t]),null}function St(e){console.error(e)}var Mt=(0,o.forwardRef)((function(e,t){var n={namespace:"MyEditor",nodes:[It,Pe.HeadingNode,Re.ListNode,Re.ListItemNode,Pe.QuoteNode,Oe.CodeNode,Oe.CodeHighlightNode,Te.TableNode,Te.TableCellNode,Te.TableRowNode,De.AutoLinkNode,De.LinkNode],theme:jt,onError:St};return(0,u.jsx)(Ie.LexicalComposer,{initialConfig:n,editorRef:t,children:(0,u.jsxs)("div",{className:"editor-container",children:[e.richText&&(0,u.jsx)(Zt,{}),e.richText&&(0,u.jsx)(Se.RichTextPlugin,{contentEditable:(0,u.jsx)(Ne.ContentEditable,{style:{border:"solid 1px rgb(204, 204, 204)",padding:"20px 15px",borderRadius:5}}),placeholder:!e.richText&&(0,u.jsx)("div",{className:"editor-placeholder",children:e.placeholder}),ErrorBoundary:Le()}),!e.richText&&(0,u.jsx)(we.PlainTextPlugin,{contentEditable:(0,u.jsx)(Ne.ContentEditable,{style:{border:"solid 1px rgb(204, 204, 204)",padding:"20px 15px",borderRadius:5}}),placeholder:!e.richText&&(0,u.jsx)("div",{className:"editor-placeholder",children:e.placeholder}),ErrorBoundary:Le()}),(0,u.jsx)("div",{className:"editor-label",children:e.label}),(0,u.jsx)(ke.HistoryPlugin,{}),e.templateVariables&&(0,u.jsx)(kt,{templateVariables:e.templateVariables,text:e.text,setText:e.setText,richText:e.richText||!1}),t&&(0,u.jsx)(wt,{editorRef:t}),(0,u.jsx)(We.ListPlugin,{}),(0,u.jsx)(Ge.LinkPlugin,{})]})})})),Pt=function(e){var t=e.name;e.apiBackend;return(0,u.jsx)(g.Z,{children:(0,u.jsx)(ue.Z,{children:t})})},Tt=function e(t,n,i,o){if(!t||!t.properties)return[null,[]];var r=t.properties,l=t.definitions,s=[];return[Object.keys(r).map((function(t){var c=n?"".concat(n,".").concat(t):t,d=r[t],A=d.type,h=d.description,v=d.title,f=d.items,m=d.widget,x=d.$ref;if("object"===A){var g=e(r[t],c,i,"".concat(o," / ").concat(t)),b=(0,a.Z)(g,2),Z=b[0],j=b[1];return s.push.apply(s,(0,p.Z)(j)),(0,u.jsx)(fe.Z,{nodeId:c,label:v||t,children:Z},c)}if("array"===A){if(f&&"object"===f.type){var y=e(f,"".concat(c,"[0]"),i,"".concat(o," / ").concat(c,"[0]")),C=(0,a.Z)(y,2),I=C[0],N=C[1];return s.push.apply(s,(0,p.Z)(N)),(0,u.jsx)(fe.Z,{nodeId:c,label:h||t,children:I},c)}if(f&&"array"===f.type){var k="object"===typeof f?e(f,"".concat(c,"[0]"),i,"".concat(o," ").concat(t)):f.map((function(n,r){var l=e(n,"".concat(c,"[0]"),i,"".concat(o," ").concat(t)),d=(0,a.Z)(l,2),A=d[0],h=d[1];return s.push.apply(s,(0,p.Z)(h)),(0,u.jsx)(fe.Z,{nodeId:"".concat(c,".").concat(r),label:"".concat(t," ").concat(r+1),children:A},"".concat(c,"[0]"))})),w=(0,a.Z)(k,1)[0];return s.push({key:"".concat(c,"[0]"),pillPrefix:"".concat(o," / ").concat(t,"[0]")}),(0,u.jsx)(fe.Z,{nodeId:c,label:h||t,children:w},"".concat(c))}if(f&&f.$ref&&Object.keys(l).find((function(e){return"#/definitions/".concat(e)===f.$ref}))){var S=e(l[f.$ref.split("/").pop()],"".concat(c,"[0]"),i,"".concat(o).concat(t,"[0] /")),M=(0,a.Z)(S,2),P=M[0],T=M[1];return s.push.apply(s,(0,p.Z)(T)),(0,u.jsx)(fe.Z,{nodeId:c,label:h||t,children:P},c)}if(f)return s.push({key:"".concat(c,"[0]"),pillPrefix:"".concat(o," ").concat(t)}),(0,u.jsx)(fe.Z,{nodeId:c,label:(0,u.jsxs)("span",{children:[t," ",(0,u.jsxs)("span",{style:{color:"#999"},children:[" - ",h]})]}),onClick:function(e){return i(e,"".concat(c,"[0]"),m)}},"".concat(c,"[0]"))}if(l&&x&&Object.keys(l).find((function(e){return"#/definitions/".concat(e)===x}))){var R=e(l[x.split("/").pop()],"".concat(c),i,"".concat(o).concat(t," /")),O=(0,a.Z)(R,2),D=O[0],G=O[1];return s.push.apply(s,(0,p.Z)(G)),(0,u.jsx)(fe.Z,{nodeId:c,label:h||t,children:D},c)}return s.push({key:c,pillPrefix:"".concat(o," ").concat(t)}),(0,u.jsx)(fe.Z,{nodeId:c,label:(0,u.jsxs)("span",{children:[t," ",(0,u.jsxs)("span",{style:{color:"#999"},children:[" - ",h]})]}),onClick:function(e){return i(e,c,m)}},c)})),s]};function Rt(e){var t,n=e.value,i=e.onChange,r=(0,o.useState)(!1),l=(0,a.Z)(r,2),s=l[0],c=l[1],d=(0,o.useState)(!1),A=(0,a.Z)(d,2),h=A[0],v=A[1],f=(0,o.useState)(!1),m=(0,a.Z)(f,2),x=m[0],b=m[1],Z=(0,o.useState)(n||""),j=(0,a.Z)(Z,2),y=j[0],C=j[1],I=e.schemas;(0,o.useEffect)((function(){h||x?c(!0):(c(!1),i&&y!==n&&i(y))}),[h,x,y,n,i]);var N=(0,o.useState)([]),k=(0,a.Z)(N,2),w=k[0],S=k[1],M=(0,o.useState)([]),P=(0,a.Z)(M,2),T=P[0],R=P[1],O=(0,o.useRef)(null);(0,o.useEffect)((function(){if(I&&I.length>0){var e=I.map((function(e,t){return Tt(e.items,"_inputs".concat(t),(function(e,t,n){var i="{{".concat(t,"}}");"output_image"===n?i="![Image]({{".concat(t,"}})"):"output_audio"===n&&(i="![Audio]({{".concat(t,"}})")),O.current.dispatchCommand(yt,i)}),e.pillPrefix)})).reduce((function(e,t){var n;return e[0].push(t[0]),(n=e[1]).push.apply(n,(0,p.Z)(t[1])),e}),[[],[]]),t=(0,a.Z)(e,2),n=t[0],i=t[1].reduce((function(e,t){return e["{{".concat(t.key,"}}")]=t.pillPrefix,e}),{});S(n),R(i)}}),[I,O,S,R]);var D=n;return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(g.Z,{onKeyDown:function(e){v(!0)},onMouseDown:function(e){v(!0)},onBlur:function(){v(!1)},sx:{marginBottom:"-20px"},children:(0,u.jsx)(Mt,{templateVariables:T,ref:O,text:D,setText:C,placeholder:(null===e||void 0===e?void 0:e.placeholder)||(null===e||void 0===e||null===(t=e.schema)||void 0===t?void 0:t.description),label:null===e||void 0===e?void 0:e.label,richText:null===e||void 0===e?void 0:e.richText})}),(0,u.jsx)("div",{onMouseEnter:function(){b(!0)},onMouseLeave:function(){b(!1),v(!1)},children:s&&w.length>0&&(0,u.jsxs)(g.Z,{style:{marginTop:30,marginBottom:10,backgroundColor:"#fffeeb",borderRadius:5,border:"1px solid #eee",padding:5},children:[(0,u.jsx)(ue.Z,{variant:"h6",style:{fontWeight:600,color:"#666"},children:"Template Variables"}),(0,u.jsx)(ue.Z,{variant:"body2",style:{marginBottom:10},children:"Below are the available variables across your input and processors. Click on a variable to insert it into the text field and use it during processing."}),w.map((function(e,t,n){return n[n.length-1-t]})).map((function(e,t){return(0,u.jsx)(me.Z,{defaultCollapseIcon:(0,u.jsx)(Ae.Z,{}),defaultExpandIcon:(0,u.jsx)(xe.Z,{}),children:(0,u.jsx)(fe.Z,{nodeId:t.toString(),label:(0,u.jsx)(Pt,{name:I[I.length-1-t].label}),children:e})},t)}))]})})]})}var Ot=n(57621),Dt=n(9585),Gt=n(15473),Wt="",zt=n.p+"static/media/openai-icon-light.5c561780c39836251114.png",Et=n.p+"static/media/openai-icon-dark.d5c1b0de202bd9e4d43c.png",Lt=n.p+"static/media/stabilityai-icon-light.ccc6b07d634cf8f92f54.png",Vt=n.p+"static/media/stabilityai-icon-dark.01311ffa23b58bb012b6.png",Bt="",Yt=n.p+"static/media/vertexai-icon-light.f8588e745a8c208b0c78.png",Ut=n.p+"static/media/vertexai-icon-dark.f8588e745a8c208b0c78.png",Ht=n.p+"static/media/localai-icon-light.1c0dd8b755dff066a8e7.png",Xt=n.p+"static/media/localai-icon-dark.1c0dd8b755dff066a8e7.png",Jt=function(e,t){switch(null===e||void 0===e?void 0:e.replaceAll(" ","").toLowerCase()){case"promptly":default:return Wt;case"openai":return t?Et:zt;case"stabilityai":return t?Vt:Lt;case"cohere":return t?"":"";case"azure":return Bt;case"elevenlabs":return"";case"google":return t?Ut:Yt;case"localai":return t?Xt:Ht}};function qt(e){var t=e.icon,n=e.title,i=e.description,r=e.stepNumber,l=e.activeStep,s=e.setActiveStep,c=e.errors,d=void 0===c?[]:c,p=e.action,A=void 0===p?null:p,h=e.children,v=l===r,f=(0,o.useState)(null),m=(0,a.Z)(f,2),x=m[0],g=m[1];return(0,u.jsxs)(Ot.Z,{sx:{width:"100%",marginTop:10,textAlign:"left",maxWidth:"900px",margin:"auto",cursor:v?"default":"pointer",boxShadow:v?"0 0 10px #449":"default","&:hover":{boxShadow:v?"default":"0 0 10px #666"}},elevation:2,children:[(0,u.jsx)(Dt.Z,{title:(0,u.jsxs)(ue.Z,{style:{fontSize:"16px",fontWeight:600,fontFamily:"Lato, sans-serif",color:v?"#fff":"#000"},children:[r,". ",n,d.length>0&&(0,u.jsxs)("span",{style:{color:"red",float:"right"},onMouseEnter:function(e){return g(e.currentTarget)},onMouseLeave:function(){return g(null)},children:["[",d.length," error",d.length>1?"s":"","]"]}),(0,u.jsx)(Gt.ZP,{id:"mouse-over-popover",sx:{pointerEvents:"none","& .MuiPopover-paper":{padding:"10px"},"& .MuiPopover-paper ol":{margin:0,paddingLeft:"15px"},"& .MuiPopover-paper li":{fontSize:"12px"}},open:Boolean(x),anchorEl:x,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:function(){return g(null)},disableRestoreFocus:!0,children:(0,u.jsx)("ol",{children:d.map((function(e,t){return(0,u.jsx)("li",{children:e.message},t)}))})})]}),subheader:(0,u.jsx)(ue.Z,{variant:"subtitle2",style:{fontSize:"14px",fontFamily:"Lato, sans-serif",color:v?"#ccc":"#6b6b6b"},children:i}),avatar:"string"===typeof t?(0,u.jsx)("img",{src:Jt(t,v),alt:t,width:40}):t,sx:{backgroundColor:v?"#2e4658":"#dce1e5",border:v?"inherit":"solid 1px #999","& .MuiCardHeader-title":{fontSize:"1.1rem",color:v?"#fff":"#000"},"& .MuiCardHeader-subheader":{fontSize:"0.8rem",color:v?"#fff":"#000"}},action:A,onClick:function(){return s(r)}}),v&&h]})}var Ft=n(82400);function Kt(e){var t,n=e.index,r=e.processors,l=e.setProcessors,s=e.activeStep,c=e.setActiveStep,d=e.outputSchemas,A=r[n],h=null===A||void 0===A?void 0:A.api_backend,v=(0,o.useState)([]),f=(0,a.Z)(v,2),m=f[0],x=f[1];return(0,o.useEffect)((function(){var e,t,n,i,a,o,r,l=[];null!==A&&void 0!==A&&null!==(e=A.api_backend)&&void 0!==e&&null!==(t=e.input_schema)&&void 0!==t&&t.required&&(null===A||void 0===A||null===(a=A.api_backend)||void 0===a||null===(o=a.input_schema)||void 0===o||o.required.forEach((function(e){null!==A&&void 0!==A&&A.input[e]?Array.isArray(null===A||void 0===A?void 0:A.input[e])&&(0===(null===A||void 0===A?void 0:A.input[e].length)||null!==A&&void 0!==A&&A.input[e].includes(""))&&l.push({message:"".concat(e," should contain at least one item")}):l.push({message:"Missing required field: ".concat(e)})})));null!==A&&void 0!==A&&null!==(n=A.api_backend)&&void 0!==n&&null!==(i=n.config_schema)&&void 0!==i&&i.required&&(null===A||void 0===A||null===(r=A.api_backend)||void 0===r||r.config_schema.required.forEach((function(e){A.config[e]?Array.isArray(A.config[e])&&(0===A.config[e].length||A.config[e].includes(""))&&l.push({message:"".concat(e," should contain at least one item")}):l.push({message:"Missing required field: ".concat(e)})})));x(l)}),[A,A.input,A.config,A.input_schema,A.config_schema]),(0,u.jsx)(qt,{icon:(null===h||void 0===h?void 0:h.icon)||(null===h||void 0===h||null===(t=h.api_provider)||void 0===t?void 0:t.name),title:null===h||void 0===h?void 0:h.name,description:null===h||void 0===h?void 0:h.description,stepNumber:n+2,activeStep:s,setActiveStep:c,errors:m,action:n===r.length-1?(0,u.jsx)(pe.Z,{style:{color:"#888",cursor:"pointer",marginTop:"3px"},onClick:function(){l(r.slice(0,-1))}}):null,children:(0,u.jsxs)(le.Z,{style:{maxHeight:400,overflow:"auto"},children:[(0,u.jsxs)(se.Z,{defaultExpanded:!0,children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"input-content",id:"input-header",style:{backgroundColor:"#dce8fb"},children:(0,u.jsx)(ue.Z,{children:"Input"})}),(0,u.jsx)(de.Z,{children:(0,u.jsx)(ve.Z,{schema:(0,i.Z)((0,i.Z)({},null===h||void 0===h?void 0:h.input_schema),{title:"",description:""}),validator:he.Z,uiSchema:(0,i.Z)((0,i.Z)({},null===h||void 0===h?void 0:h.input_ui_schema),{"ui:submitButtonOptions":{norender:!0}}),formData:r[n].input,onChange:function(e){var t=e.formData;r[n].input=t,l((0,p.Z)(r))},widgets:{TextWidget:function(e){return(0,u.jsx)(Rt,(0,i.Z)((0,i.Z)({},e),{},{schemas:d.slice(0,n+1)}))}}})})]}),(0,u.jsxs)(se.Z,{defaultExpanded:!0,children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"config-content",id:"config-header",style:{backgroundColor:"#dce8fb"},children:(0,u.jsx)(ue.Z,{children:"Configuration"})}),(0,u.jsx)(de.Z,{children:(0,u.jsx)(ve.Z,{schema:(0,i.Z)((0,i.Z)({},null===h||void 0===h?void 0:h.config_schema),{title:"",description:""}),validator:he.Z,uiSchema:(0,i.Z)((0,i.Z)({},null===h||void 0===h?void 0:h.config_ui_schema),{"ui:submitButtonOptions":{norender:!0}}),formData:r[n].config,onChange:function(e){var t=e.formData;r[n].config=t,l((0,p.Z)(r))},templates:{ObjectFieldTemplate:Ft.Z}})})]}),(0,u.jsxs)(se.Z,{children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"transformer-content",id:"transformer-header",style:{backgroundColor:"#dce8fb",display:"none"},children:(0,u.jsx)(ue.Z,{children:"Data Transformer"})}),(0,u.jsx)(de.Z,{})]})]})})}var Qt=n(21322),_t=n(70226),$t=n(89164),en=n(56890),tn=n(44617),nn=n(47976),an=n(5397),on=["string","text","number","boolean","file","select","voice"];function rn(e){var t=e.fields,n=e.setFields,o=e.readOnly,r=void 0!==o&&o,l=function(e,i){i.name=i.title.replace(/[^a-zA-Z0-9]/g,"_").toLowerCase();var a=t.map((function(t,n){return n===e?i:t}));n(a)},s=function(e,i){var a=e+i;if(!(a<0||a>=t.length)){var o=(0,p.Z)(t),r=o[e];o[e]=o[a],o[a]=r,n(o)}};return(0,u.jsxs)($t.Z,{children:[(0,u.jsx)(ue.Z,{mb:3,style:{margin:10},children:"Define the input fields you want this app to accept. These will be rendered as a form for users to fill out. If using the app via the API, the input fields will form the JSON schema for the input data."}),(0,u.jsxs)(I.Z,{sx:{"& .MuiTableCell-root":{padding:"10px 5px"},"& .MuiInputBase-input":{padding:"10px"}},children:[(0,u.jsx)(en.Z,{children:(0,u.jsxs)(k.Z,{sx:{"& .MuiTableCell-root":{fontWeight:"bold"}},children:[(0,u.jsx)(w.Z,{children:"Name"}),(0,u.jsx)(w.Z,{children:"Description"}),(0,u.jsx)(w.Z,{children:"Type"}),(0,u.jsx)(w.Z,{children:"Options"}),(0,u.jsx)(w.Z,{children:"Required"}),(0,u.jsx)(w.Z,{children:"Actions"})]})}),(0,u.jsx)(N.Z,{children:t.map((function(e,o){var d;return(0,u.jsxs)(k.Z,{style:r?{opacity:.5,pointerEvents:"none"}:{},children:[(0,u.jsx)(w.Z,{children:(0,u.jsx)(c.Z,{value:e.title,onChange:function(t){l(o,(0,i.Z)((0,i.Z)({},e),{},{title:t.target.value}))}})}),(0,u.jsx)(w.Z,{children:(0,u.jsx)(c.Z,{value:e.description,onChange:function(t){return l(o,(0,i.Z)((0,i.Z)({},e),{},{description:t.target.value}))}})}),(0,u.jsx)(w.Z,{children:(0,u.jsx)(Z.Z,{value:e.type,onChange:function(t){return l(o,(0,i.Z)((0,i.Z)({},e),{},{type:t.target.value}))},children:on.map((function(e){return(0,u.jsx)(j.Z,{value:e,children:e},e)}))})}),(0,u.jsx)(w.Z,{children:"select"===e.type?(0,u.jsx)(c.Z,{value:(null===(d=e.options)||void 0===d?void 0:d.length)>0?e.options.map((function(e){return void 0!==e.value?"".concat(e.label,":").concat(e.value):e.label})).join(","):"",onChange:function(t){return l(o,(0,i.Z)((0,i.Z)({},e),{},{options:t.target.value.split(",").map((function(e){var t=e.split(":"),n=(0,a.Z)(t,2),i=n[0],o=n[1];return{label:i,value:o?o.trim():o}}))}))},placeholder:"Label1:Value1, Label2:Value2"}):""}),(0,u.jsx)(w.Z,{children:(0,u.jsxs)(Z.Z,{value:e.required,onChange:function(t){return l(o,(0,i.Z)((0,i.Z)({},e),{},{required:t.target.value}))},children:[(0,u.jsx)(j.Z,{value:!0,children:"Yes"}),(0,u.jsx)(j.Z,{value:!1,children:"No"})]})}),(0,u.jsxs)(w.Z,{children:[(0,u.jsx)(C.Z,{onClick:function(){return s(o,-1)},size:"small",children:(0,u.jsx)(tn.Z,{})}),(0,u.jsx)(C.Z,{onClick:function(){return s(o,1)},size:"small",children:(0,u.jsx)(nn.Z,{})}),(0,u.jsx)(C.Z,{onClick:function(){return function(e){var i=t.filter((function(t,n){return n!==e}));n(i)}(o)},size:"small",children:(0,u.jsx)(an.Z,{})})]})]},o)}))})]}),(0,u.jsx)(M.Z,{variant:"contained",onClick:function(){n([].concat((0,p.Z)(t),[{name:"",title:"",description:"",type:"string",required:!1}]))},disabled:r,sx:{mt:2,textTransform:"none",float:"right",marginBottom:2,backgroundColor:"#6287ac",color:"#fff"},children:"Add Field"})]})}function ln(e){var t,n=e.appType,a=e.activeStep,o=e.setActiveStep,r=e.inputFields,l=e.setInputFields,s=e.config,c=e.setConfig;return(0,u.jsx)(qt,{icon:null!==n&&void 0!==n&&null!==(t=n.name)&&void 0!==t&&t.toLowerCase().includes("chat")?(0,u.jsx)(_t.Z,{style:{color:1===a?"white":"black",fontSize:40}}):(0,u.jsx)(Qt.Z,{style:{color:1===a?"white":"black",fontSize:40}}),title:null===n||void 0===n?void 0:n.name,description:null===n||void 0===n?void 0:n.description,stepNumber:1,activeStep:a,setActiveStep:o,children:(0,u.jsxs)(le.Z,{style:{maxHeight:400,overflow:"auto"},children:[(0,u.jsxs)(se.Z,{defaultExpanded:!0,children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"input-content",id:"input-header",style:{backgroundColor:"#dce8fb"},children:(0,u.jsx)(ue.Z,{children:"App Input"})}),(0,u.jsx)(de.Z,{children:(0,u.jsx)(rn,{fields:r,setFields:l,readOnly:"slack"===(null===n||void 0===n?void 0:n.slug)})})]}),(0,u.jsxs)(se.Z,{defaultExpanded:!0,children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"config-content",id:"config-header",style:{backgroundColor:"#dce8fb"},children:(0,u.jsx)(ue.Z,{children:"Configuration"})}),(0,u.jsx)(de.Z,{children:(0,u.jsx)(ve.Z,{schema:(0,i.Z)((0,i.Z)({},null===n||void 0===n?void 0:n.config_schema),{title:"",description:""}),validator:he.Z,uiSchema:(0,i.Z)((0,i.Z)({},null===n||void 0===n?void 0:n.config_ui_schema),{"ui:submitButtonOptions":{norender:!0}}),formData:s,onChange:function(e){var t=e.formData;c(t)},widgets:{richtext:function(e){return(0,u.jsx)(Rt,(0,i.Z)((0,i.Z)({},e),{},{richText:!0}))}},templates:{ObjectFieldTemplate:Ft.Z}})})]}),(0,u.jsxs)(se.Z,{style:{display:"none"},children:[(0,u.jsx)(ce.Z,{expandIcon:(0,u.jsx)(Ae.Z,{}),"aria-controls":"transformer-content",id:"transformer-header",style:{backgroundColor:"#dce8fb"},children:(0,u.jsx)(ue.Z,{children:"Data Transformer"})}),(0,u.jsx)(de.Z,{})]})]})})}var sn=n(23010);function cn(e){var t=e.index,n=e.activeStep,i=e.setActiveStep,a=e.outputTemplate,o=e.setOutputTemplate,r=e.outputSchemas;return(0,u.jsx)(qt,{icon:(0,u.jsx)(sn.Z,{style:{color:t+2===n?"white":"black",fontSize:40}}),title:"Application Output",description:"Configure how the application will output data",stepNumber:t+2,activeStep:n,setActiveStep:i,children:(0,u.jsx)(le.Z,{style:{maxHeight:400,overflow:"auto"},children:(0,u.jsx)("div",{style:{position:"relative"},children:(0,u.jsx)(Rt,{label:"Output Template",multiline:!0,value:(null===a||void 0===a?void 0:a.markdown)||"",onChange:function(e){o({markdown:e})},sx:{width:"100%"},placeholder:"Use the {{ }} syntax to reference data from the input. For example, {{ name }}.",schemas:r})})})})}var un,dn,pn=n(30168),An=n(93457),hn=n(88141),vn=(0,An.Z)("div")(un||(un=(0,pn.Z)(["\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  align-items: center;\n"]))),fn=(0,An.Z)("div")(dn||(dn=(0,pn.Z)(["\n  width: 1px;\n  height: 20px;\n  background-color: black;\n  margin: 4px 0;\n"])));function mn(e){var t,n,i=e.showProcessorSelector,r=e.setProcessorBackend,l=(0,h.sJ)(A.e7),s=(0,h.sJ)(A.Dg),c=(0,h.sJ)(A.YL),d=(0,h.sJ)(A.r1),p=s.IS_ORGANIZATION_MEMBER&&null!==l&&void 0!==l&&l.default_api_backend?null===c||void 0===c||null===(t=c.find((function(e){return e.id===(null===l||void 0===l?void 0:l.default_api_backend)})))||void 0===t?void 0:t.api_provider.name:"Open AI",v=s.IS_ORGANIZATION_MEMBER&&null!==l&&void 0!==l&&l.default_api_backend?null===l||void 0===l?void 0:l.default_api_backend:null===c||void 0===c||null===(n=c.find((function(e){return"ChatGPT"===e.name})))||void 0===n?void 0:n.id,f=(0,o.useState)(""),m=(0,a.Z)(f,2),x=m[0],g=m[1],y=(0,o.useState)(""),C=(0,a.Z)(y,2),I=C[0],N=C[1];return(0,o.useEffect)((function(){g(d.length>0&&p?p:""),N(c.length>0&&v?v:"")}),[p,v,d,c]),(0,u.jsxs)(vn,{children:[(0,u.jsx)(fn,{}),i&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(B.Z,{direction:"row",spacing:1,border:"solid 1px #ccc",padding:"5px",sx:{boxShadow:"0 0 10px #ccc"},children:[(0,u.jsx)(b.Z,{children:(0,u.jsxs)(Z.Z,{value:x,onChange:function(e){g(e.target.value),N("")},id:"provider-select",style:{width:120},size:"small",displayEmpty:!0,children:[(0,u.jsx)(j.Z,{value:"",children:(0,u.jsx)(ue.Z,{variant:"caption",children:"Provider"})}),d.map((function(e){return(0,u.jsx)(j.Z,{value:e.name,children:e.name},e.name)}))]})}),x&&(0,u.jsx)(b.Z,{children:(0,u.jsxs)(Z.Z,{value:I,onChange:function(e){return N(e.target.value)},id:"backend-select",placeholder:"Backend",style:{width:120},size:"small",displayEmpty:!0,children:[(0,u.jsx)(j.Z,{value:"",children:(0,u.jsx)(ue.Z,{variant:"caption",children:"Backend"})}),c.filter((function(e){return e.api_provider.name===x})).filter((function(e){return-1===((null===l||void 0===l?void 0:l.disabled_api_backends)||[]).indexOf(e.id)})).map((function(e){return(0,u.jsx)(j.Z,{value:e.id,children:e.name},e.id)}))]})}),(0,u.jsx)(M.Z,{startIcon:(0,u.jsx)(hn.Z,{fontSize:"small"}),style:{textTransform:"none"},variant:"contained",disabled:""===I,sx:{"&.Mui-disabled":{backgroundColor:"#8ac48f !important",color:"#444 !important"},"&.MuiButton-contained":{color:"#fff",backgroundColor:"#146226"}},onClick:function(){r(c.find((function(e){return e.id===I}))),g(p),N("")},children:"Processor"})]}),(0,u.jsx)(fn,{})]})]})}var xn=n(72601),gn=n(51691);function bn(e){var t=e.open,n=e.setOpen,i=e.saveApp,r=e.postSave,l=void 0===r?null:r,s=(0,o.useState)("Update app"),d=(0,a.Z)(s,2),p=d[0],A=d[1],h=function(){n(!1)};return(0,u.jsxs)(f.Z,{open:t,onClose:h,children:[(0,u.jsx)(m.Z,{children:"Create New Version"}),(0,u.jsxs)(x.Z,{children:[(0,u.jsx)(gn.Z,{children:"To save a new version of the app, please provide a description for the change."}),(0,u.jsx)(c.Z,{autoFocus:!0,margin:"dense",id:"name",label:"Describe changes",type:"text",fullWidth:!0,variant:"standard",value:p,required:!0,onChange:function(e){return A(e.target.value)},multiline:!0})]}),(0,u.jsxs)(S.Z,{children:[(0,u.jsx)(M.Z,{onClick:h,sx:{textTransform:"none"},children:"Cancel"}),(0,u.jsx)(M.Z,{onClick:function(){i(!1,p).finally((function(){A("Update app"),n(!1),l&&l()}))},variant:"contained",sx:{textTransform:"none"},children:"Save Version"})]})]})}function Zn(e){var t=e.saveApp,n=e.postSave,i=void 0===n?null:n,r=(0,o.useState)(!1),l=(0,a.Z)(r,2),s=l[0],c=l[1];return(0,u.jsxs)(B.Z,{direction:"row",gap:1,children:[(0,u.jsx)(bn,{open:s,setOpen:c,saveApp:t,postSave:i}),(0,u.jsx)(M.Z,{onClick:function(){t().finally((function(){i&&i()}))},variant:"contained",style:{textTransform:"none",margin:"20px 0",backgroundColor:"#ccc",color:"#000"},children:"Save Draft"}),(0,u.jsx)(M.Z,{onClick:function(){return c(!0)},variant:"contained",style:{textTransform:"none",margin:"20px 0"},children:"Save App"})]})}function jn(e){var t=e.app,n=e.saveApp,i=e.processors,r=e.setProcessors,l=e.appConfig,s=e.setAppConfig,c=e.appInputFields,d=e.setAppInputFields,A=e.appOutputTemplate,h=e.setAppOutputTemplate,v=e.tourInputRef,f=e.tourChainRef,m=e.tourOutputRef,x=e.tourSaveRef,b=(0,o.useState)(1),Z=(0,a.Z)(b,2),j=Z[0],y=Z[1],C=(0,o.useState)([]),I=(0,a.Z)(C,2),N=I[0],k=I[1];return(0,o.useEffect)((function(){var e=(0,xn._)(c).schema;k([{label:"1. Input",items:e,pillPrefix:"[1] Input / "}].concat((0,p.Z)(i.map((function(e,t){var n,i,a,o,r;return{label:"".concat(t+2,". ").concat(null===(n=e.api_backend)||void 0===n?void 0:n.name),pillPrefix:"[".concat(t+2,"] ").concat(null===(i=e.api_backend)||void 0===i||null===(a=i.api_provider)||void 0===a?void 0:a.name," / ").concat(null===(o=e.api_backend)||void 0===o?void 0:o.name," / "),items:null===(r=e.api_backend)||void 0===r?void 0:r.output_schema}})))))}),[c,i]),(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(B.Z,{ref:v,children:(0,u.jsx)(ln,{appType:null===t||void 0===t?void 0:t.type,activeStep:j,setActiveStep:y,config:l,setConfig:s,inputFields:c,setInputFields:d,processors:i,setProcessors:r,outputSchemas:N})}),i.map((function(e,t){return(0,u.jsxs)(B.Z,{style:{justifyContent:"center"},children:[(0,u.jsx)(mn,{showProcessorSelector:!1}),(0,u.jsx)(Kt,{index:t,processors:i,setProcessors:r,activeStep:j,setActiveStep:y,outputSchemas:N})]},t)})),(0,u.jsx)(B.Z,{style:{justifyContent:"center"},ref:f,children:(0,u.jsx)(mn,{showProcessorSelector:!0,setProcessorBackend:function(e){var t,n=(0,p.Z)(i);n.push({id:"_inputs".concat(n.length+1),api_backend:e,processor_slug:null===e||void 0===e?void 0:e.slug,provider_slug:null===e||void 0===e||null===(t=e.api_provider)||void 0===t?void 0:t.slug,endpoint:null,input:null,config:null}),r(n),y(n.length+1)}})}),(0,u.jsx)(B.Z,{ref:m,children:(0,u.jsx)(cn,{index:i.length,activeStep:j,setActiveStep:y,outputTemplate:A,setOutputTemplate:h,outputSchemas:N})}),(0,u.jsx)(B.Z,{direction:"row",gap:1,sx:{flexDirection:"row-reverse",maxWidth:"900px",margin:"auto"},ref:x,children:(0,u.jsx)(Zn,{saveApp:n})})]})}var yn=n(61721),Cn=n(43763),In=n(74765);function Nn(e){var t,n,i=e.app,r=(0,o.useState)(null),l=(0,a.Z)(r,2),s=l[0],c=l[1],d=(0,h.sJ)(A.lo),p="".concat("https:"===window.location.protocol?"wss":"ws","://").concat(window.location.host,"/ws");return(0,o.useEffect)((function(){s||c(new yn.Ws("".concat(p,"/apps/").concat(null===i||void 0===i?void 0:i.uuid,"/preview")))}),[i,s,p]),(0,u.jsxs)(g.Z,{children:["web"===(null===i||void 0===i||null===(t=i.type)||void 0===t?void 0:t.slug)&&(0,u.jsx)(In.F,{app:i,ws:s}),"text-chat"===(null===i||void 0===i||null===(n=i.type)||void 0===n?void 0:n.slug)&&(0,u.jsx)(Cn.$,{app:i,isMobile:d,ws:s})]})}var kn=n(39124),wn=n(43896),Sn=n(94721),Mn=n(56125),Pn=n(16088),Tn=n(72426),Rn=n.n(Tn),On=n(54184),Dn=n.n(On),Gn=n(87843),Wn=n(28065),zn={},En=function(e){if(zn[e])return zn[e];if(e.startsWith("Slackbot"))return zn[e]="Slack",zn[e];if(e.startsWith("Discord"))return zn[e]="Discord",zn[e];var t=new(Dn())(e),n=t.getOS(),i=t.getBrowser();return zn[e]="".concat(i.name," / ").concat(n.name),zn[e]},Ln=function(e,t){var n=t[e.id];if("request_user_email"===e.id){var i,a,o,r,l,s,c,d;if(null!==(i=t.platform_data)&&void 0!==i&&null!==(a=i.slack)&&void 0!==a&&a.user_email)return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(E.Z,{component:Wn.r,fontSize:"8",sx:{marginRight:"5px",color:"#555",verticalAlign:"middle"}}),null===(l=t.platform_data)||void 0===l||null===(s=l.slack)||void 0===s?void 0:s.user_email]});if(null!==(o=t.platform_data)&&void 0!==o&&null!==(r=o.discord)&&void 0!==r&&r.global_name)return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(E.Z,{component:Gn.r,fontSize:"8",sx:{marginRight:"5px",color:"#555",verticalAlign:"middle"}}),null===(c=t.platform_data)||void 0===c||null===(d=c.discord)||void 0===d?void 0:d.global_name]});if(null===t.request_user_email||""===t.request_user_email)return"Anonymous"}else{if("request_location"===e.id&&(null===t.request_location||""===t.request_location))return"Unknown";if("latest_created_at"===e.id)return(0,u.jsx)(U.Z,{title:Rn().utc(n).local().format("D-MMM-YYYY h:mm:ss A"),children:(0,u.jsx)("span",{children:e.format?e.format(n):n})})}return e.format?e.format(n):n},Vn=function(e,t){try{var n,a=JSON.parse(e.replace(/'/g,'"').replace(/None/g,"null").replace(/True/g,"true").replace(/False/g,"false"));return t.startsWith("Slackbot")?null===a||void 0===a||null===(n=a.text)||void 0===n?void 0:n.replace(/<@.*>/g,""):t.startsWith("Discord")?a.options.reduce((function(e,t){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},t.name,t.value))}),{}):a.input}catch(o){return{}}},Bn=function(e){var t=e.label,n=e.value,i=e.style,a=void 0===i?{}:i;return(0,u.jsxs)(g.Z,{style:a,children:[(0,u.jsx)(ue.Z,{variant:"caption",style:{fontWeight:600,color:"gray"},children:t}),(0,u.jsx)(ue.Z,{variant:"body2",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",color:"#1b5c85"},children:n})]})},Yn=function(e){var t=e.items;return t?(0,u.jsxs)(H.ZP,{container:!0,spacing:1,sx:{marginBottom:1,border:"1px solid #eee"},children:[(0,u.jsx)(H.ZP,{item:!0,xs:12,md:6,sx:{borderRight:"solid 1px #eee"},children:(0,u.jsxs)(B.Z,{direction:"column",spacing:1,sx:{marginBottom:1},children:[(0,u.jsx)(Bn,{label:"Location",value:t[0].request_location||"Unknown"}),(0,u.jsx)(Bn,{label:"IP Address",value:t[0].request_ip||"Unknown"}),(0,u.jsx)(Bn,{label:"Platform",value:En(t[0].request_user_agent)}),(0,u.jsx)(Bn,{label:"User Agent",value:t[0].request_user_agent})]})}),(0,u.jsx)(H.ZP,{item:!0,xs:12,md:6,sx:{maxHeight:"500px",overflow:"scroll"},children:(0,p.Z)(t).reverse().map((function(e,t){return(0,u.jsxs)(B.Z,{direction:"column",spacing:1,sx:{marginBottom:1},children:[(0,u.jsx)(Bn,{label:"Request",value:"object"===typeof Vn(e.request_body,e.request_user_agent)?Object.keys(Vn(e.request_body,e.request_user_agent)).map((function(t){return(0,u.jsxs)("span",{children:[(0,u.jsx)("b",{children:t}),":"," ",Vn(e.request_body,e.request_user_agent)[t]]},t)})):Vn(e.request_body,e.request_user_agent)}),(0,u.jsx)(Bn,{label:"Response",value:e.response_body,style:{textAlign:"right",paddingRight:5}}),(0,u.jsx)(ue.Z,{variant:"caption",style:{fontWeight:400,textAlign:"right",fontSize:10,color:"gray",paddingRight:5},children:Rn().utc(e.created_at).local().format("D-MMM-YYYY h:mm:ss A")}),(0,u.jsx)(Sn.Z,{})]},t)}))})]}):null};function Un(e){var t=e.app,n=(0,o.useState)(null),l=(0,a.Z)(n,2),s=l[0],c=l[1],d=(0,o.useState)([]),p=(0,a.Z)(d,2),A=p[0],h=p[1],v=(0,o.useState)({}),f=(0,a.Z)(v,2),m=f[0],x=f[1],b=(0,o.useState)(!1),Z=(0,a.Z)(b,2),j=Z[0],C=Z[1],S=(0,o.useState)({page:1,app_uuid:null===t||void 0===t?void 0:t.uuid}),M=(0,a.Z)(S,2),P=M[0],T=M[1],R=[{id:"latest_created_at",label:"Last Active",format:function(e){return Rn().utc(e).local().fromNow()}},{id:"request_user_email",label:"User"},{id:"session_key",label:"Session"}];return(0,o.useEffect)((function(){C(!0),(0,r.o)().get("/api/history/sessions?".concat(Object.keys(P).map((function(e){return"".concat(e,"=").concat(P[e])})).join("&"))).then((function(e){var t,n;c(null===(t=e.data)||void 0===t?void 0:t.count),h(((null===(n=e.data)||void 0===n?void 0:n.results)||[]).map((function(e){return(0,i.Z)((0,i.Z)({},e),{},{expand:!1})})))})).catch((function(e){console.log(e)})).finally((function(){C(!1)}))}),[s,P]),(0,u.jsxs)(H.ZP,{container:!0,spacing:1,children:[j&&(0,u.jsx)(g.Z,{children:"Loading"}),(0,u.jsxs)(y.Z,{sx:{padding:"10px 20px"},children:[(0,u.jsxs)(I.Z,{stickyHeader:!0,"aria-label":"sticky table",children:[(0,u.jsx)(en.Z,{children:(0,u.jsx)(k.Z,{children:R.map((function(e){return(0,u.jsx)(w.Z,{align:e.align,style:{fontWeight:"bold",textAlign:"left"},children:e.label},e.id)}))})}),(0,u.jsx)(N.Z,{children:A.map((function(e){return[(0,u.jsx)(k.Z,{hover:!0,role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",backgroundColor:e.expand?"#f5f5f5":"inherit"},onClick:function(){return function(e){h(A.map((function(t){return t.session_key===e.session_key?(0,i.Z)((0,i.Z)({},t),{},{expand:!t.expand}):t}))),m[e.session_key]||(0,r.o)().get("/api/history?session_key=".concat(e.session_key,"&detail=true")).then((function(t){x((0,i.Z)((0,i.Z)({},m),{},(0,Ye.Z)({},e.session_key,t.data)))}))}(e)},children:R.map((function(t){return(0,u.jsx)(w.Z,{align:t.align,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ln(t,e)},t.id)}))},e.session_key),(0,u.jsx)(k.Z,{children:(0,u.jsx)(w.Z,{style:{paddingBottom:0,paddingTop:0,border:0},colSpan:12,children:(0,u.jsx)(Mn.Z,{in:e.expand,timeout:"auto",unmountOnExit:!0,children:(0,u.jsxs)(g.Z,{sx:{margin:1},children:[!m[e.session_key]&&"Loading...  ",m[e.session_key]&&(0,u.jsx)(Yn,{items:m[e.session_key].results})]})})})},"".concat(e.session_key,"_details"))]}))})]}),(0,u.jsx)(Pn.Z,{count:Math.ceil((s||0)/20),variant:"outlined",shape:"rounded",page:P.page,onChange:function(e,t){T((0,i.Z)((0,i.Z)({},P),{},{page:t}))},sx:{marginTop:2,float:"right"}})]})]})}var Hn=n(52909);function Xn(e){var t=e.app,n=(0,o.useState)(0),i=(0,a.Z)(n,2),r=i[0],l=i[1];return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(kn.Z,{value:r,onChange:function(e,t){return l(t)},sx:{borderBottom:"1px solid #ddd",mb:2},children:[{label:"Sessions",value:0},{label:"Timeline",value:1}].map((function(e){return(0,u.jsx)(wn.Z,{label:e.label,value:e.value,sx:{textTransform:"none"}},e.value)}))}),0===r&&(0,u.jsx)(Un,{app:t}),1===r&&(0,u.jsx)(Hn.p,{filteredColumns:["created_at","request_user_email","request_location","response_time","response_status"],filter:{page:1,app_uuid:null===t||void 0===t?void 0:t.uuid}})]})}var Jn,qn=n(79012),Fn=n(85523),Kn=n(9955);function Qn(e){var t=e.app,n=(0,o.useRef)(null),i="".concat(window.location.origin,"/api/apps/").concat(null===t||void 0===t?void 0:t.uuid,"/slack/run");return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(ue.Z,{sx:{textAlign:"left"},children:"Copy the following URL in the Event Subscriptions Section in your Slack App"}),(0,u.jsx)(c.Z,{inputRef:n,value:i,variant:"outlined",fullWidth:!0,InputProps:{readOnly:!0,style:{fontFamily:"monospace",color:"#666"}},onClick:function(e){e.target.select(),navigator.clipboard.writeText(e.target.value),(0,v.yv)("Code copied successfully",{variant:"success"})}}),(0,u.jsx)(ue.Z,{sx:{textAlign:"left !important"},variant:"subtitle2",children:"Make sure to add app_mention scope in the Subscribe to bot events section"})]})}function _n(e){var t=e.app,n=(0,o.useRef)(null),i="".concat(window.location.origin,"/api/apps/").concat(null===t||void 0===t?void 0:t.uuid,"/discord/run");return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(ue.Z,{sx:{textAlign:"left"},children:"Copy the following URL in the INTERACTIONS ENDPOINT URL Section in your Discord App"}),(0,u.jsx)(c.Z,{inputRef:n,value:i,variant:"outlined",fullWidth:!0,InputProps:{readOnly:!0,style:{fontFamily:"monospace",color:"#666"}},onClick:function(e){e.target.select(),navigator.clipboard.writeText(e.target.value),(0,v.yv)("Code copied successfully",{variant:"success"})}}),(0,u.jsx)(ue.Z,{sx:{textAlign:"left"},variant:"subtitle2",children:"Make sure to add bot scopes in the OAuth2 URL Generator section of your app."})]})}function $n(e){var t,n,i=e.app,r=(0,o.useRef)(null),l="text-chat"===(null===i||void 0===i||null===(t=i.type)||void 0===t?void 0:t.slug),s=(0,o.useState)(l),d=(0,a.Z)(s,2),p=d[0],A=d[1],h=null!==i&&void 0!==i&&i.is_published?'<script async src="'.concat(window.location.origin,'/static/js/embed-v1.js"><\/script>\n<promptly-app-embed published-app-id="').concat(null===i||void 0===i?void 0:i.published_uuid,'"').concat(p?' chat-bubble="true"':"",' host="').concat(window.location.origin,'"></promptly-app-embed>'):"Please publish the app to get the embed code";return(0,o.useEffect)((function(){r.current&&r.current.select()}),[]),(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(ue.Z,{sx:{textAlign:"left"},children:"Copy the following code and paste it in your website body section to embed this app on your page."}),(0,u.jsx)(c.Z,{inputRef:r,multiline:!0,rows:6,value:h,variant:"outlined",fullWidth:!0,InputProps:{readOnly:!0,style:{fontFamily:"monospace",color:"#666"}},autoFocus:!0,onClick:function(e){e.target.select(),navigator.clipboard.writeText(e.target.value),(0,v.yv)("Code copied successfully",{variant:"success"})}}),"text-chat"===(null===i||void 0===i||null===(n=i.type)||void 0===n?void 0:n.slug)&&(0,u.jsx)(qn.Z,{children:(0,u.jsx)(Fn.Z,{control:(0,u.jsx)(Kn.Z,{checked:p,onChange:function(e){return A(e.target.checked)}}),label:"Chat Bubble"})})]})}function ei(e){var t=e.app,n=e.integration;return"slack"===n?(0,u.jsx)(Qn,{app:t}):"discord"===n?(0,u.jsx)(_n,{app:t}):(0,u.jsx)($n,{app:t})}function ti(e){var t=e.allowedDomains,n=e.setAllowedDomains;return(0,u.jsx)(c.Z,{helperText:"Domains that are allowed to embed this app. Use comma to separate multiple domains",variant:"outlined",label:"Allowed Domains",value:null===t||void 0===t?void 0:t.join(", "),onChange:function(e){var t=e.target.value.split(",");n(t.map((function(e){return e.trim()})))},size:"small"})}function ni(e){var t=e.app,n=e.webConfig,a=e.saveApp,o=e.setWebConfig;return(0,u.jsxs)(g.Z,{children:[(0,u.jsxs)(B.Z,{direction:"column",gap:2,children:[(0,u.jsx)(ei,{app:t,integration:"web"}),(0,u.jsx)(ti,{allowedDomains:null===n||void 0===n?void 0:n.allowed_sites,setAllowedDomains:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{allowed_sites:e}))}}),(0,u.jsx)(c.Z,{helperText:"Domain name pointing to the app. Coming soon for Pro users",id:"domain",label:"Domain",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{domain:e.target.value}))},disabled:!0,defaultValue:(null===n||void 0===n?void 0:n.domain)||"",size:"small"})]}),(0,u.jsx)(B.Z,{direction:"row",gap:1,sx:{flexDirection:"row-reverse",maxWidth:"900px",margin:"auto"},children:(0,u.jsx)(Zn,{saveApp:a})})]})}function ii(e){var t=e.app,n=e.saveApp,a=e.slackConfig,o=e.setSlackConfig;return(0,u.jsxs)(g.Z,{children:[(0,u.jsxs)(B.Z,{direction:"column",gap:2,children:[(0,u.jsx)(c.Z,{id:"app_id",label:"App ID",helperText:"Application ID",onChange:function(e){return o((0,i.Z)((0,i.Z)({},a),{},{app_id:e.target.value}))},defaultValue:(null===a||void 0===a?void 0:a.app_id)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"bot_token",label:"Bot Token",helperText:"Bot token to use for sending messages to Slack. Make sure the Bot has access to app_mentions:read and chat:write scopes. This token is available at Features > OAuth & Permissions in your app page. More details https://api.slack.com/authentication/oauth-v2",onChange:function(e){return o((0,i.Z)((0,i.Z)({},a),{},{bot_token:e.target.value}))},defaultValue:(null===a||void 0===a?void 0:a.bot_token)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"verification_token",label:"Verification Token",helperText:"Verification token to verify the request from Slack. This token is available at Features > Basic Information in your app page. More details https://api.slack.com/authentication/verifying-requests-from-slack",onChange:function(e){return o((0,i.Z)((0,i.Z)({},a),{},{verification_token:e.target.value}))},defaultValue:(null===a||void 0===a?void 0:a.verification_token)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"signing_secret",label:"Signing Secret",helperText:"Signing secret to verify the request from Slack. This secret is available at Features > Basic Information in your app page. More details https://api.slack.com/authentication/verifying-requests-from-slack",onChange:function(e){return o((0,i.Z)((0,i.Z)({},a),{},{signing_secret:e.target.value}))},defaultValue:(null===a||void 0===a?void 0:a.signing_secret)||"",size:"small"}),(0,u.jsx)(ei,{app:t,integration:"slack"})]}),(0,u.jsx)(B.Z,{direction:"row",gap:1,sx:{flexDirection:"row-reverse",maxWidth:"900px",margin:"auto"},children:(0,u.jsx)(Zn,{saveApp:n})})]})}function ai(e){var t=e.app,n=e.discordConfig,a=e.saveApp,o=e.setDiscordConfig;return(0,u.jsxs)(g.Z,{children:[(0,u.jsxs)(B.Z,{direction:"column",gap:2,children:[(0,u.jsx)(c.Z,{id:"app_id",label:"Application ID",helperText:"App ID of the Discord app. Your application's ID can be found in the URL of the your application console.",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{app_id:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.app_id)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"slash_command_name",label:"Slash Command Name",helperText:"The name of the slash command that will be used to trigger the app.",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{slash_command_name:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.slash_command_name)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"slash_command_description",label:"Slash Command Description",helperText:"The description of the slash command that will be used to trigger the app.",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{slash_command_description:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.slash_command_description)||"Promptly App",size:"small"}),(0,u.jsx)(c.Z,{id:"bot_token",label:"Bot Token",helperText:"Bot token of the Discord app. Your bot's token can be found in the Bot section of the your application console.",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{bot_token:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.bot_token)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"public_key",label:"Public Key",helperText:"Public key of the Discord app. Your public key can be found in the Bot section of the your application console.",onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{public_key:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.public_key)||"",size:"small"}),(0,u.jsx)(c.Z,{id:"slash_command_id",label:"Slash Command ID",helperText:"Slash command ID of the Discord app. Your slash command ID can be found in the Slash Commands section of the your application console.",disabled:!0,onChange:function(e){return o((0,i.Z)((0,i.Z)({},n),{},{slash_command_id:e.target.value}))},defaultValue:(null===n||void 0===n?void 0:n.slash_command_id)||"",size:"small"}),(0,u.jsx)(ei,{app:t,integration:"discord"})]}),(0,u.jsx)(B.Z,{direction:"row",gap:1,sx:{flexDirection:"row-reverse",maxWidth:"900px",margin:"auto"},children:(0,u.jsx)(Zn,{saveApp:a})})]})}var oi=["title","titleId"];function ri(){return ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ri.apply(this,arguments)}function li(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function si(e,t){var n=e.title,i=e.titleId,a=li(e,oi);return o.createElement("svg",ri({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--iconoir",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:t,"aria-labelledby":i},a),n?o.createElement("title",{id:i},n):null,Jn||(Jn=o.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 21H8c-1.105 0-2-.894-2-1.999V14c0-1-1.5-2-1.5-2S6 11 6 10V5a2 2 0 0 1 2-2h1m6 18h1c1.105 0 2-.894 2-1.999V14c0-1 1.5-2 1.5-2S18 11 18 10V5a2 2 0 0 0-2-2h-1"})))}var ci,ui,di=o.forwardRef(si),pi=(n.p,["title","titleId"]);function Ai(){return Ai=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Ai.apply(this,arguments)}function hi(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function vi(e,t){var n=e.title,i=e.titleId,a=hi(e,pi);return o.createElement("svg",Ai({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--ic",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:t,"aria-labelledby":i},a),n?o.createElement("title",{id:i},n):null,ci||(ci=o.createElement("path",{fill:"currentColor",d:"M11 14.17L8.83 12L11 9.83L9.59 8.41L6 12l3.59 3.59zm3.41 1.42L18 12l-3.59-3.59L13 9.83L15.17 12L13 14.17z"})),ui||(ui=o.createElement("path",{fill:"currentColor",d:"M19 3h-4.18C14.4 1.84 13.3 1 12 1s-2.4.84-2.82 2H5c-.14 0-.27.01-.4.04a2.008 2.008 0 0 0-1.44 1.19c-.1.23-.16.49-.16.77v14c0 .27.06.54.16.78s.25.45.43.64c.27.27.62.47 1.01.55c.13.02.26.03.4.03h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7-.25c.41 0 .75.34.75.75s-.34.75-.75.75s-.75-.34-.75-.75s.34-.75.75-.75zM19 15v4H5V5h14v10z"})))}var fi,mi=o.forwardRef(vi),xi=(n.p,["title","titleId"]);function gi(){return gi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},gi.apply(this,arguments)}function bi(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Zi(e,t){var n=e.title,i=e.titleId,a=bi(e,xi);return o.createElement("svg",gi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--tabler",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:t,"aria-labelledby":i},a),n?o.createElement("title",{id:i},n):null,fi||(fi=o.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1zm0 8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1zm10-1h6m-6 4h6m-6 4h6"})))}var ji,yi=o.forwardRef(Zi),Ci=(n.p,["title","titleId"]);function Ii(){return Ii=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Ii.apply(this,arguments)}function Ni(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function ki(e,t){var n=e.title,i=e.titleId,a=Ni(e,Ci);return o.createElement("svg",Ii({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--heroicons",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:t,"aria-labelledby":i},a),n?o.createElement("title",{id:i},n):null,ji||(ji=o.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0 1 12 15a9.065 9.065 0 0 0-6.23-.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0 1 12 21a48.25 48.25 0 0 1-8.135-.687c-1.718-.293-2.3-2.379-1.067-3.61L5 14.5"})))}var wi,Si=o.forwardRef(ki),Mi=(n.p,["title","titleId"]);function Pi(){return Pi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Pi.apply(this,arguments)}function Ti(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Ri(e,t){var n=e.title,i=e.titleId,a=Ti(e,Mi);return o.createElement("svg",Pi({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--ic",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:t,"aria-labelledby":i},a),n?o.createElement("title",{id:i},n):null,wi||(wi=o.createElement("path",{fill:"currentColor",d:"M8.7 15.9L4.8 12l3.9-3.9a.984.984 0 0 0 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59a.996.996 0 0 0 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0a.984.984 0 0 0 0-1.4zm6.6 0l3.9-3.9l-3.9-3.9a.984.984 0 0 1 0-1.4a.984.984 0 0 1 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6a.984.984 0 0 1-1.4 0a.984.984 0 0 1 0-1.4z"})))}var Oi=o.forwardRef(Ri),Di=(n.p,n(38399)),Gi=(n(73905),n(56339),n(21052),n(71333),n(83449)),Wi=n(47283),zi=n(82851);function Ei(e){var t,n=e.app,i=(0,o.useState)(""),r=(0,a.Z)(i,2),l=r[0],s=r[1],c=(0,o.useState)(""),d=(0,a.Z)(c,2),p=d[0],v=d[1],f=(0,o.useState)(""),m=(0,a.Z)(f,2),x=m[0],b=m[1],Z=(0,o.useState)(""),j=(0,a.Z)(Z,2),y=j[0],C=j[1],I=(0,o.useState)(""),N=(0,a.Z)(I,2),k=N[0],w=N[1],S=(0,o.useState)(""),M=(0,a.Z)(S,2),P=M[0],T=M[1],R=(0,o.useState)("1"),O=(0,a.Z)(R,2),D=O[0],G=O[1],W=(0,o.useState)("1"),z=(0,a.Z)(W,2),E=z[0],L=z[1],V=(0,h.sJ)(A.rc);return(0,o.useEffect)((function(){s("import requests\n\nPROMPTLY_TOKEN = '".concat(null===V||void 0===V?void 0:V.token,"'    \nurl = '").concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,'/run\'\n\npayload = {\n  "input": {\n    ').concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),'\n  },\n  "stream": False,\n}\nheaders = {\n  "Content-Type": "application/json",\n  "Authorization": "Token " + PROMPTLY_TOKEN,\n}\n\nresponse = requests.request("POST", url, headers=headers, json=payload)\n\nprint(response.text.encode(\'utf8\'))')),v("import requests\n\nPROMPTLY_TOKEN = '".concat(null===V||void 0===V?void 0:V.token,"'    \nurl = '").concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,'/run\'\n\npayload = {\n  "input": {\n    ').concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),'\n  },\n  "stream": True,\n}\nheaders = {\n  "Content-Type": "application/json",\n  "Authorization": "Token " + PROMPTLY_TOKEN,\n}\n\nresponse = requests.post(url, headers=headers, json=payload, stream=True)\nfor line in response.iter_lines():\n  if line:\n    print(line.decode(\'utf8\'))')),b("\ncurl --location --request POST \\\n'".concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,"/run' \\\n--header 'Content-Type: application/json' \\\n--header 'Authorization: Token ").concat(null===V||void 0===V?void 0:V.token,"' \\\n--data-raw '{\n  \"input\": {\n    ").concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),'\n  },\n  "stream": false\n}\'')),C("\ncurl --location --request POST \\\n'".concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,"/run' \\\n--header 'Content-Type: application/json' \\\n--header 'Authorization: Token ").concat(null===V||void 0===V?void 0:V.token,"' \\\n--data-raw '{\n  \"input\": {\n    ").concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),'\n  },\n  "stream": true\n}\'')),w("const axios = require('axios');\n\nconst url = '".concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,"/run';\nconst PROMPTLY_TOKEN = '").concat(null===V||void 0===V?void 0:V.token,'\';\nconst payload = {\n  "input": {\n    ').concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),"\n  },\n  \"stream\": false,\n}\nconst headers = {\n    'Content-Type': 'application/json',\n    'Authorization': 'Token ' + PROMPTLY_TOKEN,\n\n  }\n\naxios.post(url, payload, { headers: headers})\n  .then((response) => {\n  console.log(response.data);\n});")),T("const axios = require('axios');\n\nconst url = '".concat(window.location.origin,"/api/apps/").concat(null===n||void 0===n?void 0:n.uuid,"/run';\nconst PROMPTLY_TOKEN = '").concat(null===V||void 0===V?void 0:V.token,'\';\nconst payload = {\n  "input": {\n    ').concat(null===n||void 0===n?void 0:n.data.input_fields.map((function(e){var t=e.name;return'"'.concat(t,'": "<').concat(t,'_value>"')})).join(",\n    "),"\n  },\n  \"stream\": true,\n}\nconst headers = {\n    'Content-Type': 'application/json',\n    'Authorization': 'Token ' + PROMPTLY_TOKEN,\n\n  }\naxios\n  .post(url, payload, { headers, responseType: 'stream' })\n  .then(response => {\n    response.data.on('data', line => {\n      if (line) {\n        console.log(line.toString('utf8'));\n      }\n    });\n  })\n  .catch(error => {\n    console.error(error);\n  });\n\n"))}),[null===n||void 0===n||null===(t=n.data)||void 0===t?void 0:t.input_fields,null===n||void 0===n?void 0:n.uuid,null===V||void 0===V?void 0:V.token]),(0,u.jsx)("div",{children:(0,u.jsxs)(g.Z,{sx:{textAlign:"left"},children:[(0,u.jsx)(ue.Z,{variant:"h6",children:"Non-Streaming"}),(0,u.jsxs)(Gi.ZP,{value:D,children:[(0,u.jsx)(g.Z,{sx:{borderBottom:1},children:(0,u.jsxs)(Wi.Z,{onChange:function(e,t){G(t)},"aria-label":"Non streaming code examples",children:[(0,u.jsx)(wn.Z,{label:"Python",value:"1",sx:{textTransform:"none"}}),(0,u.jsx)(wn.Z,{label:"cURL",value:"2",sx:{textTransform:"none"}}),(0,u.jsx)(wn.Z,{label:"JavaScript",value:"3",sx:{textTransform:"none"}})]})}),(0,u.jsxs)(zi.Z,{value:"1",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your Python application"})}),(0,u.jsx)(Di.ZP,{mode:"python",theme:"dracula",value:l,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"300px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]}),(0,u.jsxs)(zi.Z,{value:"2",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your terminal"})}),(0,u.jsx)(Di.ZP,{mode:"sh",theme:"dracula",value:x,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"300px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]}),(0,u.jsxs)(zi.Z,{value:"3",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your JavaScript app"})}),(0,u.jsx)(Di.ZP,{mode:"javascript",theme:"dracula",value:k,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"300px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]})]}),(0,u.jsx)(ue.Z,{variant:"h6",mt:3,children:"Streaming"}),(0,u.jsxs)(Gi.ZP,{value:E,children:[(0,u.jsx)(g.Z,{sx:{borderBottom:1},children:(0,u.jsxs)(Wi.Z,{onChange:function(e,t){L(t)},"aria-label":"Non streaming code examples",children:[(0,u.jsx)(wn.Z,{label:"Python",value:"1",sx:{textTransform:"none"}}),(0,u.jsx)(wn.Z,{label:"cURL",value:"2",sx:{textTransform:"none"}}),(0,u.jsx)(wn.Z,{label:"JavaScript",value:"3",sx:{textTransform:"none"}})]})}),(0,u.jsxs)(zi.Z,{value:"1",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your Python application"})}),(0,u.jsx)(Di.ZP,{mode:"python",theme:"dracula",value:p,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"350px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]}),(0,u.jsxs)(zi.Z,{value:"2",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your terminal"})}),(0,u.jsx)(Di.ZP,{mode:"sh",theme:"dracula",value:y,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"300px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]}),(0,u.jsxs)(zi.Z,{value:"3",children:[(0,u.jsx)(B.Z,{gap:1,children:(0,u.jsx)(ue.Z,{variant:"body2",mb:2,children:"Use the following code to run the app from your JavaScript app"})}),(0,u.jsx)(Di.ZP,{mode:"javascript",theme:"dracula",value:P,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",height:"350px",width:"100%",maxWidth:"600px"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})]})]})]})})}var Li=n(94070),Vi=n(2199),Bi=n(70242),Yi=n(74512),Ui=n(15825),Hi=n(763);function Xi(e){var t=e.appData,n=e.setAppData,r=e.page,l=(0,o.useState)({}),s=(0,a.Z)(l,2),c=s[0],d=s[1],p=(0,o.useCallback)((function(e){var a=r.schema.properties;Object.keys(e).forEach((function(n){if(a[n]&&a[n].path){var i=a[n].path;(0,Hi.set)(t,i,void 0===e[n]?"":e[n])}})),n((0,i.Z)({},t))}),[t,r,n]);return(0,o.useEffect)((function(){var e;if(r){var n=Object.keys((null===r||void 0===r||null===(e=r.schema)||void 0===e?void 0:e.properties)||{}).reduce((function(e,n){var i=r.schema.properties[n].path;return(0,Hi.set)(e,n,(0,Hi.get)(t,i,null)),e}),{});d((function(e){return(0,i.Z)((0,i.Z)({},e),n)}))}}),[t,r]),r?(0,u.jsx)(g.Z,{children:(0,u.jsx)(ve.Z,{schema:(0,i.Z)((0,i.Z)({},r.schema),{title:"",description:""}),uiSchema:r.ui_schema,validator:he.Z,formData:c,onChange:function(e){var t=e.formData;d(t),p(t)},widgets:{richtext:function(e){return(0,u.jsx)(Rt,(0,i.Z)((0,i.Z)({},e),{},{richText:!0}))}}})}):null}function Ji(e){var t=e.app,n=(0,l.s0)();return(0,u.jsx)(g.Z,{mt:5,mb:5,children:(0,u.jsxs)(B.Z,{gap:2,children:[(0,u.jsx)(Li.Z,{severity:"success",icon:!1,children:"\ud83c\udf89 Congratulations! You have now saved your app. Follow the links below to test, publish and integrate the app into other surfaces"}),(0,u.jsx)(ue.Z,{variant:"h6",children:"Test your app"}),(0,u.jsx)(Vi.Z,{variant:"outlined","aria-label":"outlined button group",children:(0,u.jsx)(M.Z,{sx:{textTransform:"none"},onClick:function(){return n("/apps/".concat(t.uuid,"/preview"))},children:"Preview"})}),(0,u.jsx)(ue.Z,{variant:"h6",children:"Use the below links to embed your app into your Website, Slack or Discord channels"}),(0,u.jsxs)(Vi.Z,{variant:"outlined","aria-label":"outlined button group",children:[(0,u.jsx)(M.Z,{sx:{textTransform:"none"},onClick:function(){return n("/apps/".concat(t.uuid,"/integrations/website"))},children:"Website"}),(0,u.jsx)(M.Z,{sx:{textTransform:"none"},onClick:function(){return n("/apps/".concat(t.uuid,"/integrations/discord"))},children:"Discord"}),(0,u.jsx)(M.Z,{sx:{textTransform:"none"},onClick:function(){return n("/apps/".concat(t.uuid,"/integrations/slack"))},children:"Slack"})]})]})})}function qi(e){var t=e.app,n=e.setApp,r=e.saveApp,l=e.appTemplate,s=(0,o.useState)(0),c=(0,a.Z)(s,2),d=c[0],p=c[1],v=(0,o.useState)(!1),f=(0,a.Z)(v,2),m=f[0],x=f[1],b=(0,o.useState)(!1),Z=(0,a.Z)(b,2),j=Z[0],y=Z[1],C=(0,h.sJ)(A.lo),I=(null===l||void 0===l?void 0:l.pages)||[];return null!==t&&void 0!==t&&t.template&&l?(0,u.jsxs)(g.Z,{sx:{textAlign:"left"},children:[(0,u.jsx)(Bi.Z,{activeStep:d,orientation:C?"vertical":"horizontal",children:I.map((function(e,t){return(0,u.jsx)(Yi.Z,{children:(0,u.jsx)(Ui.Z,{optional:(0,u.jsx)(ue.Z,{variant:"caption",children:e.description}),children:e.title})},t)}))}),(0,u.jsx)("p",{}),(0,u.jsxs)(o.Fragment,{children:[I.map((function(e,a){return(0,u.jsx)(Xi,{appData:null===t||void 0===t?void 0:t.data,setAppData:function(e){n({data:(0,i.Z)((0,i.Z)({},null===t||void 0===t?void 0:t.data),e)})},page:a===d?e:null},a)})),m&&(0,u.jsx)(P.Z,{}),!m&&j&&(0,u.jsx)(Ji,{app:t}),(0,u.jsxs)(g.Z,{sx:{display:"flex",flexDirection:"row",pt:2},children:[(0,u.jsx)(M.Z,{color:"inherit",disabled:0===d,onClick:function(){p((function(e){return e-1})),y(!1)},sx:{mr:1,textTransform:"none",margin:"20px 0"},variant:"outlined",children:"Back"}),(0,u.jsx)(g.Z,{sx:{flex:"1 1 auto"}}),d===I.length-1&&(0,u.jsx)(Zn,{saveApp:r,postSave:function(){x(!0),p(I.length),x(!1),y(!0)}}),d<I.length-1&&(0,u.jsx)(M.Z,{onClick:function(){p((function(e){return e+1})),y(!1)},variant:"contained",sx:{textTransform:"none",margin:"20px 0"},children:"Next"})]})]})]}):null}var Fi=n(74165),Ki=n(15861),Qi=n(71747),_i=n(55768),$i=n(52601),ea=n(58054),ta=n(69258),na=n(60142),ia={"ui:order":["expected_output"],"ui:options":{label:!1},expected_output:{"ui:widget":"textarea","ui:options":{rows:5}}},aa={type:"object",properties:{expected_output:{type:"string",title:"Add your expected output here"}},required:["expected_output"]};function oa(e){var t,n,l=e.open,s=e.handleCancelCb,d=e.onSubmitCb,A=e.modalTitle,h=void 0===A?"Create a Test Set":A,v=e.testSet,g=e.app,b=(0,o.useState)((null===v||void 0===v?void 0:v.name)||""),Z=(0,a.Z)(b,2),j=Z[0],y=Z[1],C=(0,o.useState)(!1),I=(0,a.Z)(C,2),N=I[0],k=I[1],w=(0,o.useState)({}),P=(0,a.Z)(w,2),T=P[0],R=P[1],O=(0,o.useState)({}),D=(0,a.Z)(O,2),G=D[0],W=D[1];return(0,u.jsxs)(f.Z,{open:l,onClose:s,children:[(0,u.jsx)(m.Z,{children:h}),(0,u.jsx)(x.Z,{sx:{minWidth:"400px"},children:(0,u.jsxs)(B.Z,{spacing:2,children:[(0,u.jsx)(c.Z,{label:"Test Set Name",value:j,onChange:function(e){return y(e.target.value)},disabled:!!v,required:!0,defaultValue:(null===v||void 0===v?void 0:v.name)||"Untitled",size:"small",style:{width:"100%",marginTop:"6px"},error:N}),(0,u.jsx)(Sn.Z,{orientation:"center",style:{marginBottom:"-10px"},children:"Input"}),(0,u.jsx)(ve.Z,{schema:null===(t=(0,xn._)((null===g||void 0===g||null===(n=g.data)||void 0===n?void 0:n.input_fields)||[]))||void 0===t?void 0:t.schema,validator:he.Z,uiSchema:(0,i.Z)((0,i.Z)({},(null===g||void 0===g?void 0:g.input_ui_schema)||{}),{"ui:submitButtonOptions":{norender:!0},"ui:DescriptionFieldTemplate":function(){return null},"ui:TitleFieldTemplate":function(){return null}}),formData:T,onChange:function(e){var t=e.formData;R(t)}}),(0,u.jsx)(Sn.Z,{orientation:"center",style:{marginBottom:"-10px"},children:"Expected Output"}),(0,u.jsx)(ve.Z,{schema:aa,validator:he.Z,uiSchema:(0,i.Z)((0,i.Z)({},ia),{"ui:submitButtonOptions":{norender:!0},"ui:DescriptionFieldTemplate":function(){return null},"ui:TitleFieldTemplate":function(){return null}}),formData:G,onChange:function(e){var t=e.formData;W(t)}})]})}),(0,u.jsxs)(S.Z,{children:[(0,u.jsx)(M.Z,{onClick:s,children:"Cancel"}),",",(0,u.jsx)(M.Z,{variant:"contained",onClick:function(){if(v)(0,r.o)().post("/api/apptestsets/".concat(v.uuid,"/add_entry"),(0,i.Z)((0,i.Z)({},G),{},{input_data:T})).then((function(e){v.testcases=[].concat((0,p.Z)(v.testcases),[e.data]),d((0,i.Z)({},v))}));else{if(""===j)return void k(!0);(0,r.o)().post("/api/apps/".concat(g.uuid,"/testsets"),{name:j}).then((function(e){var t=e.data;(0,r.o)().post("/api/apptestsets/".concat(t.uuid,"/add_entry"),(0,i.Z)((0,i.Z)({},G),{},{input_data:T})).then((function(e){t.testcases=[e.data],d((0,i.Z)({},t))}))}))}},children:"Submit"})]})]})}var ra=n(28121);function la(e){var t=e.app,n=(0,o.useState)(""),l=(0,a.Z)(n,2),s=l[0],c=l[1],d=(0,o.useState)(""),p=(0,a.Z)(d,2),A=p[0],h=p[1],v=(0,o.useState)(null),f=(0,a.Z)(v,2),m=f[0],x=f[1],b=(0,o.useState)(!1),Z=(0,a.Z)(b,2),j=Z[0],y=Z[1],I=(0,o.useState)(!1),N=(0,a.Z)(I,2),k=N[0],w=N[1],S=(0,o.useState)({}),P=(0,a.Z)(S,2),T=P[0],R=P[1],O=(0,o.useState)("Create Test Set"),D=(0,a.Z)(O,2),G=D[0],W=D[1],z=(0,o.useState)(null),E=(0,a.Z)(z,2),L=E[0],V=E[1],B=(0,o.useState)({}),Y=(0,a.Z)(B,2),U=Y[0],X=Y[1],J=(0,o.useState)({}),q=(0,a.Z)(J,2),F=q[0],K=q[1],Q=(0,o.useState)({}),_=(0,a.Z)(Q,2),$=_[0],ee=_[1];function te(){return te=(0,Ki.Z)((0,Fi.Z)().mark((function e(n){var a,o,l,s;return(0,Fi.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:X((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"RUNNING"))})),a=function(){var e=(0,Ki.Z)((0,Fi.Z)().mark((function e(n){var a;return(0,Fi.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return K((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"RUNNING"))})),e.next=3,(0,r.o)().post("/api/apps/".concat(t.uuid,"/run"),{input:n.input_data,stream:!1});case 3:return a=e.sent,ee((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,a.data))})),K((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"COMPLETED"))})),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),o=function(e,t){for(var n=[],i=0,a=e.length;i<a;i+=t)n.push(e.slice(i,i+t));return n},l=o(n.testcases,2),s=0;case 5:if(!(s<l.length)){e.next=11;break}return e.next=8,Promise.all(l[s].map(a)).catch(console.error);case 8:s++,e.next=5;break;case 11:X((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"COMPLETED"))}));case 12:case"end":return e.stop()}}),e)}))),te.apply(this,arguments)}(0,o.useEffect)((function(){var e={};(0,r.o)().get("/api/apps/".concat(t.uuid,"/testsets")).then((function(t){t.data.forEach((function(t){e[t.uuid]=(0,i.Z)((0,i.Z)({},t),{},{testcases:t.testcases.map((function(e){return(0,i.Z)({},e)}))}),R(e)}))})).catch((function(e){}))}),[R,null===t||void 0===t?void 0:t.uuid]);var ne=[{title:"Name",dataIndex:"name",key:"name",width:"35%"},{title:"Last Modified",width:"25%",dataIndex:"last_updated_at",ellipsis:!0,key:"last_updated_at",render:function(e){return(0,u.jsx)(na.P,{value:e})}},{title:"Status",width:"20%",render:function(e){var t=U[e.uuid];return void 0===t?null:"RUNNING"===t?(0,u.jsx)(Be.Z,{label:"Running",color:"primary"}):"COMPLETED"===t?(0,u.jsx)(Be.Z,{label:"Completed",color:"success"}):null}},{title:"Action",width:"20%",key:"operation",render:function(e){return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(C.Z,{onClick:function(){W("Add Test Entry"),V(e),y(!0)},children:(0,u.jsx)(ea.Z,{})}),(0,u.jsx)(C.Z,{onClick:function(){x(e),c("Delete Test Set"),h((0,u.jsxs)("div",{children:["Are you sure you want to delete"," ",(0,u.jsx)("span",{style:{fontWeight:"bold"},children:e.name})," ?"]})),w(!0)},children:(0,u.jsx)($i.Z,{})}),(0,u.jsx)(C.Z,{onClick:function(){X({}),K({}),ee({}),function(e){te.apply(this,arguments)}(e)},children:(0,u.jsx)(ta.Z,{})})]})}}];return(0,u.jsxs)("div",{id:"tests-page",children:[(0,u.jsxs)(H.ZP,{span:24,style:{padding:"10px"},children:[(0,u.jsx)(H.ZP,{item:!0,style:{width:"100%",padding:"15px 0px"},children:(0,u.jsx)(M.Z,{onClick:function(){y(!0)},type:"primary",variant:"contained",sx:{float:"left",marginBottom:"10px",textTransform:"none"},children:"Create Test Set"})}),(0,u.jsx)(H.ZP,{item:!0,style:{width:"100%"},children:(0,u.jsx)(_i.Z,{dataSource:Object.values(T),columns:ne,pagination:!1,expandable:{expandedRowRender:function(e){var n=e.testcases,a=[{title:"Input Data",width:"20%",render:function(e){return(0,u.jsx)(Qi.Z,{disabled:!0,minRows:3,value:JSON.stringify(e.input_data,null,2)})}},{title:"Expected Output",width:"20%",scroll:{x:400},render:function(e){return(0,u.jsx)(Qi.Z,{disabled:!0,minRows:3,value:e.expected_output})}},{title:"Output Data",width:"20%",render:function(e){var t=$[e.uuid];return(0,u.jsx)(Qi.Z,{disabled:!0,minRows:3,value:t?JSON.stringify(null===t||void 0===t?void 0:t.output,null,2):""})}},{title:"Status",width:"10%",render:function(e){var t=F[e.uuid];return t?"RUNNING"===t?(0,u.jsx)(Be.Z,{label:"Running",color:"primary"}):"COMPLETED"===t?(0,u.jsx)(Be.Z,{label:"Completed",color:"success"}):null:null}},{title:"Action",width:"10%",key:"operation",render:function(e){return(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(C.Z,{onClick:function(){x(e),c("Delete Test Case"),h((0,u.jsxs)("div",{children:["Are you sure you want to delete"," ",(0,u.jsx)("span",{style:{fontWeight:"bold"},children:e.name})," ","?"]})),w(!0)},children:(0,u.jsx)($i.Z,{})}),(0,u.jsx)(C.Z,{onClick:function(){var n;X({}),K({}),ee({}),n=e,X((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.testset_uuid,"RUNNING"))})),K((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"RUNNING"))})),(0,r.o)().post("/api/apps/".concat(t.uuid,"/run"),{input:n.input_data,stream:!1}).then((function(e){ee((function(t){return(0,i.Z)((0,i.Z)({},t),{},(0,Ye.Z)({},n.uuid,null===e||void 0===e?void 0:e.data))}))})).catch((function(e){})).finally((function(){X((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.testset_uuid,"COMPLETED"))})),K((function(e){return(0,i.Z)((0,i.Z)({},e),{},(0,Ye.Z)({},n.uuid,"COMPLETED"))}))}))},children:(0,u.jsx)(ta.Z,{})})]})}}];return(0,u.jsx)(_i.Z,{columns:a,dataSource:n,rowKey:function(e){return e.uuid},pagination:!1})},expandRowByClick:!0,defaultExpandAllRows:!0},rowKey:function(e){return e.uuid},style:{width:"100%"}})})]}),j&&(0,u.jsx)(oa,{open:j,testSet:L,modalTitle:G,handleCancelCb:function(){V(null),y(!1)},onSubmitCb:function(e){R((function(t){return t[e.uuid]=e,t})),V(null),y(!1)},app:t}),k&&(0,u.jsx)(ra.Z,{id:m,title:s,text:A,open:k,onOk:function(e){void 0===(null===e||void 0===e?void 0:e.testset_uuid)?(0,r.o)().delete("/api/apptestsets/".concat(e.uuid)).then((function(t){R((function(t){return delete t[e.uuid],t}))})).finally((function(){w(!1)})):(0,r.o)().delete("/api/apptestcases/".concat(e.uuid)).then((function(t){R((function(t){var n=t[e.testset_uuid];return n.testcases=n.testcases.filter((function(t){return t.uuid!==e.uuid})),t[e.testset_uuid]=n,t}))})).finally((function(){w(!1)}))},onCancel:function(){w(!1)}})]})}var sa=n(24082),ca=n(88705);n(30033);function ua(e){var t=e.open,n=e.setOpen,i=e.data;return(0,u.jsx)(sa.Z,{open:t,onClose:function(){return n(!1)},"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:(0,u.jsx)(g.Z,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:600,bgcolor:"background.paper",boxShadow:24,p:4},children:(0,u.jsx)(Di.ZP,{mode:"yaml",theme:"dracula",value:i,editorProps:{$blockScrolling:!0},setOptions:{useWorker:!1,showGutter:!1},style:{borderRadius:"5px",width:"100%"},onLoad:function(e){e.renderer.setScrollMargin(10,0,10,0),e.renderer.setPadding(10)}})})})}function da(e){var t=e.app,n=(0,o.useState)([]),i=(0,a.Z)(n,2),l=i[0],s=i[1],c=(0,o.useState)(!1),d=(0,a.Z)(c,2),p=d[0],A=d[1],h=(0,o.useState)(""),v=(0,a.Z)(h,2),f=v[0],m=v[1];return(0,o.useEffect)((function(){t&&(0,r.o)().get("/api/apps/".concat(t.uuid,"/versions")).then((function(e){s(e.data)}))}),[t]),(0,u.jsxs)(g.Z,{children:[(0,u.jsx)(ua,{open:p,setOpen:A,data:f}),(0,u.jsx)(y.Z,{children:(0,u.jsxs)(I.Z,{children:[(0,u.jsx)(en.Z,{children:(0,u.jsxs)(k.Z,{children:[(0,u.jsx)(w.Z,{style:{fontWeight:"600"},children:"Version"}),(0,u.jsx)(w.Z,{style:{fontWeight:"600"},children:"Comment"}),(0,u.jsx)(w.Z,{style:{fontWeight:"600"},children:"Status"}),(0,u.jsx)(w.Z,{style:{fontWeight:"600"},children:"Last Updated"})]})}),(0,u.jsx)(N.Z,{children:l.map((function(e,n){return(0,u.jsxs)(k.Z,{children:[(0,u.jsxs)(w.Z,{onClick:function(){A(!0),(0,r.o)().get("/api/apps/".concat(t.uuid,"/versions/").concat(e.version,"?draft=").concat(e.is_draft?"True":"False")).then((function(e){m(ca.ZP.dump(e.data.data))}))},style:{textDecoration:"underline",cursor:"pointer"},children:["v",e.version]}),(0,u.jsx)(w.Z,{children:e.comment}),(0,u.jsx)(w.Z,{children:e.is_draft?"Draft":"Published"}),(0,u.jsx)(w.Z,{children:Rn().utc(e.last_updated_at).local().fromNow()})]},n)}))})]})})]})}var pa=[{name:"Editor",value:"editor",icon:(0,u.jsx)(J.Z,{})},{name:"Preview",value:"preview",icon:(0,u.jsx)(q.Z,{})},{name:"History",value:"history",icon:(0,u.jsx)(F.Z,{})},{name:"Tests",value:"tests",icon:(0,u.jsx)(E.Z,{component:Si})},{name:"Versions",value:"versions",icon:(0,u.jsx)(E.Z,{component:X.Z})},{name:"Integrations",icon:(0,u.jsx)(E.Z,{component:mi}),children:[{name:"Website",value:"integrations/website",icon:(0,u.jsx)(E.Z,{component:Oi})},{name:"API",value:"integrations/api",icon:(0,u.jsx)(E.Z,{component:di})},{name:"Discord",value:"integrations/discord",icon:(0,u.jsx)(E.Z,{component:Gn.r})},{name:"Slack",value:"integrations/slack",icon:(0,u.jsx)(E.Z,{component:Wn.r})}]}];function Aa(e){var t,n,s=(0,l.UO)().appId,c=e.page,p=(0,h.sJ)(A.YL),f=(0,o.useState)([]),m=(0,a.Z)(f,2),x=m[0],b=m[1],Z=(0,o.useState)(null),j=(0,a.Z)(Z,2),y=j[0],C=j[1],I=(0,o.useState)(!1),N=(0,a.Z)(I,2),k=N[0],w=N[1],S=(0,o.useState)(!1),T=(0,a.Z)(S,2),R=T[0],O=T[1],X=(0,o.useState)(!1),J=(0,a.Z)(X,2),q=J[0],F=J[1],Q=(0,o.useState)(!1),_=(0,a.Z)(Q,2),te=_[0],ne=_[1],ie=(0,o.useState)([]),ae=(0,a.Z)(ie,2),oe=ae[0],le=ae[1],se=(0,l.s0)(),ce=(0,o.useState)(!0),ue=(0,a.Z)(ce,2),de=ue[0],pe=ue[1],Ae=(0,o.useState)(null),he=(0,a.Z)(Ae,2),ve=he[0],fe=he[1],me=(0,o.useState)({}),xe=(0,a.Z)(me,2),ge=xe[0],be=xe[1],Ze=(0,o.useState)([]),je=(0,a.Z)(Ze,2),ye=(je[0],je[1]),Ce=(0,o.useState)(3),Ie=(0,a.Z)(Ce,2),Ne=Ie[0],ke=Ie[1],we=(0,o.useState)(c||"editor"),Se=(0,a.Z)(we,2),Me=Se[0],Pe=Se[1],Te=(0,h.sJ)(A.rc),Re=((0,h.sJ)(A.Dg),(0,o.useRef)(null)),Oe=(0,o.useRef)(null),De=(0,o.useRef)(null),Ge=(0,o.useRef)(null),We=(0,o.useRef)(null),ze=(0,o.useRef)(null);(0,o.useEffect)((function(){s&&(0,r.o)().get("/api/apps/".concat(s)).then((function(e){var t,n,i,a=e.data;pe(!1),C(a),w(a.is_published),b((null===a||void 0===a||null===(t=a.data)||void 0===t?void 0:t.input_fields)||[{name:"question",title:"Question",description:"Modify your fields here",type:"string",required:!0}]),le((null===a||void 0===a||null===(n=a.data)||void 0===n?void 0:n.processors)||(null===a||void 0===a?void 0:a.processors)||[]),be((null===a||void 0===a||null===(i=a.data)||void 0===i?void 0:i.output_template)||(null===a||void 0===a?void 0:a.output_template)),ke(a.visibility),null!==a&&void 0!==a&&a.template&&(Pe(c||"template"),(0,r.o)().get("/api/apps/templates/".concat(e.data.template.slug)).then((function(e){fe(e.data)})))})).catch((function(e){window.location.href="/apps"}))}),[s,c]),(0,o.useEffect)((function(){var e,t=new Set;null===y||void 0===y||null===(e=y.processors)||void 0===e||e.map((function(e){var t,n,i,a;return[null===(t=e.apiBackend)||void 0===t||null===(n=t.api_provider)||void 0===n?void 0:n.slug,null===(i=e.apiBackend)||void 0===i||null===(a=i.api_provider)||void 0===a?void 0:a.name]})).forEach((function(e){var n=(0,a.Z)(e,2),i=n[0],o=n[1];"promptly"===i?Te.openai_key||(t=t.add("Open AI")):Te["".concat(i,"_key")]||(t=t.add(o))})),ye(Array.from(t))}),[null===y||void 0===y?void 0:y.processors,Te]),(0,o.useEffect)((function(){var e;null!==y&&void 0!==y&&null!==(e=y.data)&&void 0!==e&&e.processors&&le(y.data.processors.map((function(e){return(0,i.Z)((0,i.Z)({},e),{},{api_backend:p.find((function(t){return t.slug===e.processor_slug&&t.api_provider.slug===e.provider_slug}))})})))}),[null===y||void 0===y||null===(t=y.data)||void 0===t?void 0:t.processors,p]),(0,o.useEffect)((function(){C((function(e){return(0,i.Z)((0,i.Z)({},e),{},{data:(0,i.Z)((0,i.Z)({},null===e||void 0===e?void 0:e.data),{},{input_fields:x})})}))}),[x]),(0,o.useEffect)((function(){C((function(e){return(0,i.Z)((0,i.Z)({},e),{},{output_template:ge})}))}),[ge]);var Ee=function(e){return new Promise((function(t,n){(0,r.o)().post("/api/apps",e).then((function(e){(0,v.yv)("App created successfully",{variant:"success",autoHideDuration:500}),se("/apps/".concat(e.data.uuid)),t(e)})).catch((function(e){return n(e)}))}))},Le=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return new Promise((function(n,i){var a,o,l,c={name:null===y||void 0===y?void 0:y.name,description:"",draft:e,comment:t,config:null===y||void 0===y||null===(a=y.data)||void 0===a?void 0:a.config,app_type:null===y||void 0===y||null===(o=y.type)||void 0===o?void 0:o.id,type_slug:null===y||void 0===y||null===(l=y.type)||void 0===l?void 0:l.slug,input_fields:x,output_template:ge,web_config:(null===y||void 0===y?void 0:y.web_config)||{},slack_config:(null===y||void 0===y?void 0:y.slack_config)||{},discord_config:(null===y||void 0===y?void 0:y.discord_config)||{},processors:oe.map((function(e,t){var n,i,a;return{id:"_inputs".concat(t+1),provider_slug:null===(n=e.api_backend)||void 0===n||null===(i=n.api_provider)||void 0===i?void 0:i.slug,processor_slug:null===(a=e.api_backend)||void 0===a?void 0:a.slug,config:e.config,input:e.input}}))};s?(0,r.o)().patch("/api/apps/".concat(s),c).then((function(e){C(e.data),(0,v.yv)("App updated successfully",{variant:"success"}),n(e.data)})).catch((function(e){i(e)})):Ee(c).then((function(e){return n(e.data)})).catch((function(e){return i(e)}))}))};return de?(0,u.jsx)(P.Z,{}):(0,u.jsxs)("div",{id:"app-edit-page",style:{margin:10},children:[(0,u.jsx)($,{tourRef1:Re,tourRef2:Oe,tourRef3:De,tourRef4:Ge,tourRef5:We,tourRef6:ze,page:Me}),(0,u.jsx)(L.Z,{position:"sticky",sx:{backgroundColor:"inherit",zIndex:100},ref:Re,children:(null===y||void 0===y?void 0:y.type)&&(0,u.jsx)(V.Z,{elevation:1,style:{width:"100%",padding:"10px 20px"},children:(0,u.jsxs)(B.Z,{direction:"row",spacing:1,children:[(0,u.jsxs)(B.Z,{direction:"column",children:[(0,u.jsxs)(B.Z,{direction:"row",spacing:1.2,children:[(0,u.jsx)(d,{appName:y.name,setAppName:function(e){return C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{name:e})}))}}),y.owner_email!==Te.user_email&&(0,u.jsxs)("span",{style:{color:"gray",lineHeight:"40px"},children:["shared by ",(0,u.jsx)("b",{children:y.owner_email})]}),y.owner_email===Te.user_email&&0===y.visibility&&y.last_modified_by_email&&(0,u.jsxs)("span",{style:{color:"gray",lineHeight:"40px"},children:["Last modified by"," ",(0,u.jsx)("b",{children:y.last_modified_by_email===Te.user_email?"You":y.last_modified_by_email})]})]}),k&&(0,u.jsxs)(B.Z,{direction:"row",spacing:.2,sx:{justifyContent:"left"},children:[(0,u.jsx)(Y.Z,{href:"".concat(window.location.origin,"/app/").concat(y.published_uuid),target:"_blank",rel:"noreferrer",variant:"body2",children:"".concat(window.location.origin,"/app/").concat(y.published_uuid)}),(0,u.jsx)(ee.Z,{visibility:Ne,published:k,setShowSharingModal:F,disabled:y.owner_email!==Te.user_email})]})]}),(0,u.jsxs)(B.Z,{direction:"row",spacing:1,sx:{justifyContent:"flex-end",flexGrow:1,flexShrink:1,alignItems:"center"},children:[(0,u.jsx)(G,{show:q,setShow:F,app:y,setIsPublished:w,setAppVisibility:ke}),(0,u.jsx)(D,{show:R,setShow:O,app:y,setIsPublished:w,setAppVisibility:ke,setReadAccessibleBy:function(e){return C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{read_accessible_by:e})}))},setWriteAccessibleBy:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{write_accessible_by:e})}))}}),(0,u.jsx)(W,{show:te,setShow:ne,app:y,setIsPublished:w}),s&&y&&(0,u.jsx)(U.Z,{arrow:!0,title:null!==y&&void 0!==y&&y.has_live_version?k?"Unpublish App":"Publish App":"Please save App before publishing",children:(0,u.jsx)("span",{children:(0,u.jsx)(M.Z,{variant:"contained",color:"success",style:{textTransform:"none"},disabled:y.owner_email!==Te.user_email||!(null!==y&&void 0!==y&&y.has_live_version),startIcon:k?(0,u.jsx)(K.Z,{}):(0,u.jsx)(z.Z,{}),onClick:function(){return k?ne(!0):O(!0)},children:k?"Unpublish":"Publish"})})})]})]})})}),(0,u.jsxs)(B.Z,{children:[(0,u.jsx)("p",{}),!1]}),(0,u.jsxs)(H.ZP,{container:!0,sx:{maxWidth:"1200px !important",margin:"auto"},rowSpacing:1,columnSpacing:{xs:0,sm:1},children:[(0,u.jsx)(H.ZP,{item:!0,md:3,xs:12,children:(0,u.jsx)(g.Z,{sx:{width:"100%"},children:(0,u.jsx)(re,{menuItems:ve?[{name:ve.name,value:"template",icon:(0,u.jsx)(E.Z,{component:yi})}].concat(pa):pa,selectedMenuItem:Me,setSelectedMenuItem:function(e){Pe(e),se("/apps/".concat(s,"/").concat(e))},tourRef:ze})})}),(0,u.jsx)(H.ZP,{item:!0,md:9,xs:12,children:(0,u.jsxs)(g.Z,{sx:{alignSelf:"flex-start"},children:["editor"===Me&&(0,u.jsx)(jn,{processors:oe,setProcessors:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{processors:e,data:(0,i.Z)((0,i.Z)({},t.data),{},{processors:e})})})),le(e)},appConfig:(null===y||void 0===y||null===(n=y.data)||void 0===n?void 0:n.config)||{},setAppConfig:function(e){return C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{config:e,data:(0,i.Z)((0,i.Z)({},null===t||void 0===t?void 0:t.data),{},{config:e})})}))},appInputFields:x,setAppInputFields:b,appOutputTemplate:ge,setAppOutputTemplate:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{output_template:e,data:(0,i.Z)((0,i.Z)({},null===t||void 0===t?void 0:t.data),{},{output_template:e})})})),be(e)},app:y,setApp:C,saveApp:Le,tourInputRef:Oe,tourChainRef:De,tourOutputRef:Ge,tourSaveRef:We}),"preview"===Me&&(0,u.jsx)(Nn,{app:y}),"history"===Me&&(0,u.jsx)(Xn,{app:y}),"tests"===Me&&(0,u.jsx)(la,{app:y}),"versions"===Me&&(0,u.jsx)(da,{app:y}),"integrations/website"===Me&&(0,u.jsx)(ni,{app:y,webConfig:(null===y||void 0===y?void 0:y.web_config)||{},setWebConfig:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{web_config:e})}))},saveApp:Le}),"integrations/slack"===Me&&(0,u.jsx)(ii,{app:y,slackConfig:(null===y||void 0===y?void 0:y.slack_config)||{},setSlackConfig:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{slack_config:e})}))},saveApp:Le}),"integrations/discord"===Me&&(0,u.jsx)(ai,{app:y,discordConfig:(null===y||void 0===y?void 0:y.discord_config)||{},setDiscordConfig:function(e){C((function(t){return(0,i.Z)((0,i.Z)({},t),{},{discord_config:e})}))},saveApp:Le}),"integrations/api"===Me&&(0,u.jsx)(Ei,{app:y}),"template"===Me&&(0,u.jsx)(qi,{app:y,setApp:function(e){return C((function(t){return(0,i.Z)((0,i.Z)({},t),e)}))},appTemplate:ve,saveApp:Le})]})})]})]})}}}]);
//# sourceMappingURL=39.71945b9e.chunk.js.map